我试图使用cordova构建我的应用程序,但是我收到了这个错误:
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/AnimRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/AnimatorRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/AnyRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/ArrayRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/AttrRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/BoolRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/ColorRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/DimenRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/DrawableRes;
这是我的grade androidDependecies
armv7Debug
+--- LOCAL: gcm.jar
+--- me.leolin:ShortcutBadger:1.1.2
+--- com.android.support:support-v4:23.1.1
| \--- LOCAL: internal_impl-23.1.1.jar
+--- org.xwalk:xwalk_core_library:15.44.384.13
+--- android:CordovaLib:unspecified:debug
\--- android.phonegap-facebook-plugin:FacebookLib:unspecified:debug
+--- LOCAL: android-support-v4.jar
+--- LOCAL: bolts-android-1.1.2.jar
\--- android:CordovaLib:unspecified:debug
它表明 android.phonegap-facebook-plugin:FacebookLib 需要已经调用的android-support-v4.jar,因此它会被重复。
我的问题是我在FacebookLib \ libs下的项目文件夹中只有一个 android-support-v4.jar ,这是我能找到的唯一一个。
在我的build.gradle中,我评论了compile "com.android.support:support-v4:+"
,当我使用Android Studio进行构建时,它可以正常运行,但是当我ionic build android
我的更改被覆盖时
答案 0 :(得分:3)
在Android Studio中打开build.gradle(模块Android)并将这些行放在头部:
apply plugin: 'com.android.application'
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.google.android.gms', module: 'play-services'
}
这一行帮助了我,并阻止了两次包含几个模块的构建。
答案 1 :(得分:0)
在build.gradle文件中添加以下行:
lintOptions {
abortOnError false
}
如果使用Cordova:
cordova plugin remove android.support.v4
要编译Android Studio应用程序而不丢失任何内容,只需使用app文件夹中已存在的gradlew即可。您正在使用的方法没有利用您在设置这些文件时所做的工作。我建议用这个:
./gradlew build
请记住,这只是gradle,适用于其他gradle命令,如:
./gradlew clean