gpt4 book ai didi

java.lang.RuntimeException : No dex files created at

转载 作者:太空宇宙 更新时间:2023-11-04 12:42:41 25 4
gpt4 key购买 nike

我重新安装了 Android Studio 2.0,并创建了一个使用 KitKat 从空 Activity 开始的新项目。当我尝试运行我的应用程序时,它会抛出此异常:

Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: No dex files created at D:\FooBar\app\build\intermediates\transforms\dex\debug\folders\1000\10\instant-run_f87637c93f940f7e851927751cc4a5b7e4ab0be3

我到处寻找,例如将“multiDexEnabled true”添加到模块 build.gradle 中的 defaultConfig block 中。但是我似乎找不到类似的问题,现有的解决方案似乎也无法解决我的问题。

我已附上我能想到的所有最新代码和配置文件,这可能有助于解决此问题。

这是我的 AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.joseph.foobar">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
</activity>
</application>
</manifest>

我的activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ScrollScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:id="@+id/MainLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context="com.joseph.foobar.MainActivity">
<TextView
android:id="@+id/MainTitle"
android:text="@string/app_name"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:textColor="#ffffff"/>
</RelativeLayout>
</ScrollView>

我唯一的类MainActivity.java

package com.joseph.foobar;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate()");

setContentView(R.layout.activity_main);

RelativeLayout container = (RelativeLayout)findViewById(R.id.MainLayout);
Button button = new Button(this);
RelativeLayout.LayoutParams params4 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params4.addRule(RelativeLayout.BELOW, R.id.MainTitle);
params4.addRule(RelativeLayout.CENTER_HORIZONTAL);
button.setLayoutParams(params4);
container.addView(button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), MainActivity.class);
startActivity(intent);
}});
}

@Override
protected void onPause() {
Log.d(TAG, "onPause()");
super.onPause();
}

@Override
protected void onResume() {
super.onResume();
Log.d(TAG, "onResume()");
}

@Override
public void onStart() {
super.onStart();
Log.d(TAG, "onStart()");
}

@Override
public void onDestroy() {
super.onDestroy();
Log.d(TAG, "onDestroy()");
}

@Override
public void onRestart() {
super.onRestart();
Log.d(TAG, "onRestart()");
}

private static final String TAG = "FooBarMain";
}

我的模块build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "com.joseph.foobar"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
}

我的项目build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

最佳答案

要删除临时错误,我只需关闭 android studio 的即时运行功能。如果您想禁用即时运行,只需执行以下操作:

1) File => Setting.

2) Click to Build,Execution,Deployment.

3) Click Instant Run

4) Uncheck to Enable Instant Run to hot swap code.....

如果您想启用即时运行,只需执行以下操作:

1) File => Setting.

2) Click to Build,Execution,Deployment.

3) Click Instant Run

4) check to Enable Instant Run to hot swap code.....

关于java.lang.RuntimeException : No dex files created at,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36673826/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com