【发布时间】:2017-08-18 16:23:15
【问题描述】:
我正在尝试创建一个依赖于 java 库模块中的 java 代码的 android 应用程序,但是每当我尝试使用该 java 库中的任何对象时,我总是得到以下结果
任务 ':app:transformClassesWithDexForDebug' 执行失败。
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1 .8.0_121\bin\java.exe'' 以非零退出值 1 结束
我查看了以下Execution failed for task ':app:transformClassesWithDexForDebug' while implementing Google sign in for Android 并尝试了几乎所有建议,但仍然无法构建。我的 java 库确实使用了 android 使用的 json 库,我收到了一些警告,但它说它将被忽略
这是我的 build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "pwils33.familymap"
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries false
incremental true
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile project(':shared')
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:support-v4:25.3.0'
compile 'com.android.support:multidex:1.0.1'
}
我正在将该模块用于我构建的另一个 java 应用程序,因此我无法将其转换为 android 库。任何帮助将不胜感激
编辑我也尝试让我的应用程序成为一个多 dex 应用程序,但这也不起作用,这是我的应用程序清单
<?xml version="1.0" encoding="utf-8"?>
<manifest package="pwils33.familymap"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="android.support.multidex.MultiDexApplication">
<activity android:name=".activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
【问题讨论】: