Gradle dependency causing error "Invalid Magic Number" - android

I have a project on GitHub that I work on both in the office at home. For about 2 months it was working fine on both machines. Then two weeks ago, it stopped running on my home PC, but still works fine on my work PC.
This is the error I get:
:app:shrinkDebugMultiDexComponents FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:shrinkDebugMultiDexComponents'.
java.io.IOException: Can't read [D:\dev\gitRepo\app\android\app\build\intermediates\multi-dex\debug\allclasses.jar] (Can't process class [__MACOSX/com/stripe/android/._BuildConfig.class] (Invalid magic number [51607] in class))
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
The stripe package that is giving me errors is a 3rd party library that you can find here. I list it as a dependency in my build.gradle file exactly as they say to.
compile 'com.stripe:stripe-android:+'
I have commented out all code pertaining the stripe and the app runs completely fine, so I do know it has something to do with how I am handling that package.
Unfortunately I don't remember exactly what I had done to make this stop working. I do think that the week before this happened I upgraded Android Studio, and spent a considerable amount of time messing with ProGuard configurations.
What I have tried:
Working on the master branch where no ProGuard changes have been made.
Uninstalling and Reinstalling Android Studio
Re-cloning the git repo
Installing API 17 (stripe for eclipse requires this. Not Studio but I gave it a shot).
Contacting stripe customer support but they had no clue.
This stack overflow post. However, there is no Mac computer that has touched the project nor have I personally zipped anything related to stripe.
From here, converted the magic number from Hex to ASCII. The result was Q` which I do not recognize.
I think it may have something to do with something I did for ProGuard, but I don't understand how. I'm on a completely different branch than any Proguard work, with a clean AndroidStudio install, with a clean repository clone, and the project still works fine when I'm in the office.
EDIT
I am running this on the debug BuildType. These are my 3 gradle files. The first is for the entire Project, the second is for the Application Module, and the third is for a local android library Module.
Project build.gradle:
buildscript {
repositories {
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
allprojects {
repositories {
jcenter()
maven{ url 'http://download.crashlytics.com/maven' }
}
}
Android Application Module build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.app.android"
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
minSdkVersion 16
targetSdkVersion 22
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
buildConfigField 'Boolean', 'enableCrashlytics', 'true'
}
debug {
buildConfigField 'Boolean', 'enableCrashlytics', 'false'
}
adhoc {
debuggable true
signingConfig signingConfigs.debug
buildConfigField 'Boolean', 'enableCrashlytics', 'true'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile project(':localLibrary')
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'commons-io:commons-io:2.4'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:support-v4:22.0.1'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'
compile 'com.google.android.gms:play-services-maps:8.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'io.card:android-sdk:5.0.1'
compile 'com.stripe:stripe-android:+'
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
}
Local Android Library Module build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.1.0'
compile 'com.google.code.gson:gson:2.2.2'
compile 'com.android.support:multidex:1.0.0'
compile group: 'org.apache.httpcomponents' , name: 'httpmime' , version: '4.3.5'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5'
}

This problem is probably related to the version of Java that you are running. I had a similar problem and discovered that Java 8 was used for the build. When I changed to Java 7, this build problem was fixed.
In Android Studio go to
File -> Project Structure -> SDK Location
The JDK Location should be Java 1.7.x (Java 7)

Yeah verify both machines have the same Java version, and indeed the same version of Android Studio. The only other thing I can think of is that maybe Stripe is using the build tools bundled with AS to build your apk, and the ones you have installed by default differ slightly and are missing something - see this post I made on a similar problem I had.

Related

Lint found fatal errors while assembling a release target - gradle error?

I am using AS 3.1 with gradle-4.5-all.zip and main build.gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
An app-level build.gradle looks like following:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example"
minSdkVersion 14
targetSdkVersion 27
versionCode 6
versionName "1.00"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
implementation 'ch.acra:acra:4.6.1'
implementation 'commons-validator:commons-validator:1.5.0'
implementation 'com.android.support:support-v13:27.1.1'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.google.zxing:core:3.3.0'
}
and works fine when I set up a debug version under AS 3.1 to my phone, but when I try to make release apk it shows me an error:
Lint found fatal errors while assembling a release target.
To proceed, either fix the issues identified by lint, or modify your build
script as follows:
...
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
As I can see in the lint-results-release-fatal.html the reason is:
I would not like to change lintOptions to supress this error because it doesn't solve the problem, it just hide it. More over, when I use
implementation files('libs/commons-validator-1.5.0.jar')
instead of
implementation 'commons-validator:commons-validator:1.5.0'
the release apk is compiled without any error messages. Is it a some gradle bug or what!?
P.S. I have attached a file androidDependencies.txt. Package commons-logging doesn't appears in the dependencies at all! How is it possible to get the solution of above problem analysing this file?
the release apk is compiled without any error messages. Is it a some
gradle bug or what!?
It seems like that dependency has a package which conflicts with the Android itself. The reason why it works without implementation and adding it manually, it might be that it downloads needed packages when you add it to be downloaded from maven repository and that's when the issue came up.
Anyways, the solution at these situations might be using the latest version:
implementation 'commons-validator:commons-validator:1.6'
Or, exclude it as follows:
implementation ('commons-validator:commons-validator:1.5.0') {
exclude group: 'commons-logging', module: 'commons-logging'
}
Note: The following part can't be helpful (for this issue) since the error says:
Commons-logging defines classes that conflict with classes now
provided by Android
You could go deeply by running ./gradlew app:dependencies in the IDE terminal to see which one conflicts with the Android itself and then excluding it as above.

Fatal Exception: java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV23

On my latest release a few of my users (less than 0.2%) are getting a crash because android.support.v7.app.AppCompatDelegateImplV23 can not be found. I can not reproduce the issue, I'm only getting reports over crashlytics. I have used apktool to extract the files out of my apk and I can see AppCompatDelegateImplV23.smali in there. Any idea what could be happening?
This is my compile line on gradle:
compile 'com.android.support:appcompat-v7:23+'
This is the exception:
Fatal Exception: java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV23
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:133)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:117)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:456)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
at MyActivityClass.onCreate(MyActivityClass.java:353)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:117)
EDIT: This is my main gradle file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
jcenter() // version plugin support
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.android.tools.build:gradle:1.3.1'
}
allprojects {
repositories {
jcenter()
}
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
signingConfigs {
config {
......
}
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 14
}
}
defaultConfig {
applicationId "mypackage"
minSdkVersion 14
targetSdkVersion 23
versionCode some number
versionName "some version number"
multiDexEnabled true
signingConfig signingConfigs.config
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(output.outputFile.parent,"myapk.apk")
}
}
}
debug {
signingConfig signingConfigs.config
}
}
repositories {
mavenCentral()
mavenLocal()
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'AndroidManifest.xml'
exclude 'META-INF/beans.xml'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
}
productFlavors {
}
dexOptions {
// preDexLibraries = false
jumboMode = true
javaMaxHeapSize "2g"
//doesn't seem to be supported with multidex
// incremental true
}
lintOptions{
disable 'MissingTranslation'
disable 'ExtraTranslation'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//multidex
compile 'com.android.support:multidex:1.0.0'
//support libs
compile 'com.android.support:support-v4:23+'
compile 'com.android.support:appcompat-v7:23+'
compile 'com.android.support:cardview-v7:23+'
compile 'com.android.support:design:23+'
//app invites
compile 'com.google.android.gms:play-services-appinvite:8+'
compile 'com.google.android.gms:play-services-analytics:8+'
//chromecast
compile 'com.google.android.gms:play-services-cast:8+'
compile 'com.android.support:mediarouter-v7:23+'
//plus button
compile 'com.google.android.gms:play-services-plus:8+'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile 'com.github.navasmdc:MaterialDesign:1.+#aar'
//material lib needs it
compile 'com.nineoldandroids:library:2.4.+'
compile 'com.facebook.stetho:stetho:1+'
compile 'com.facebook.stetho:stetho-okhttp:1+'
//debugCompile 'com.squareup.leakcanary:leakcanary-android:1+'
debugCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1+'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1+'
compile 'com.makeramen:dragsortadapter:1.3+'
compile 'com.github.amlcurran.showcaseview:library:5.0.0'
}
EDIT: just had a new report but for a different version of the same class
Fatal Exception: java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:135)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:117)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:456)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
at MyActivity.onCreate(MyActivity.java:353)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2044)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2105)
at android.app.ActivityThread.access$600(ActivityThread.java:133)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1211)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4795)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(NativeStart.java)
EDIT: I've just gone over a lot of the reports, some are for AppCompatDelegateImplV23 and some are for AppCompatDelegateImplV14, some involved XPosed but most don't. The one thing that is common to all of them is that they are all for rooted phones.
First of all, we need to understand why java.lang.NoClassDefFoundError error occurs :
So the answer is that when there is a class file that your code depends on and it is present at compile time but not found at runtime. Look for differences in your build time and runtime classpaths.
So there are some options by that you can remove this error:
1) Make preDexLibraries to true:
dexOptions {
preDexLibraries = true
jumboMode = true
javaMaxHeapSize "2g"
//doesn't seem to be supported with multi dex
// incremental true
}
2) There may be the problem with the incremental build system. So try to try to remove your build folder from your project and Rebuild the project OR Right click on your project -> "Open module settings" -> Dependencies tab -> check if Export is checked for your library
3) You need to do more than just provide MultiDex support.
multiDexEnabled = true in your defaultConfig block
Include compile 'com.android.support:multidex:1.0.0' in your dependencies
Have your Application class extend MultiDexApplication instead of just Application. Alternatively, you can call MultiDex.install() in attachBaseContext() of your application
For more reference you can check the below link which has provided more advance understanding of multi dex.
https://developer.android.com/tools/building/multidex.html
4) Or at last you can add jar files of V7 into your project's libs folder and then add it your build System.
5) Also try removing the jar files as well as it still includes the com.android.support:support-v4:23+ as gradle has a repository where it downloads the jars delcared like compile 'compile 'com.android.support:appcompat-v7:23+'
Hope this can give you some clue about your error.
My guess is that the problem is due to the xposed framework. At the bottom of the stack trace, you can find that the zygote was started by the xposed framework.
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:117)
This means that the user is using a custom Android rom with the xposed framework installed. The framework is usually used to modify the behavior of the Android framework (and any app of course) code by injecting new code at run-time.
You can check how it works at: https://github.com/rovo89/XposedBridge/tree/art/app/src/main/java/de/robv/android/xposed
Since the code behavior can be altered in various degrees depending on what mods are installed via the xposed framework, I cannot pinpoint the exact cause of your exception. However, if all the stack traces you have got start with the XposedBrigde.main(), then I can say that your problem is due to the exposed framework or the mods installed via the framework.

Android: ExternalSystemException: String index out of range: -130 building release

So, just updated to Android Studio 1.4 Beta 4 and having trouble building a release build. I can build a debug build fine. This is the error I get:
ExternalSystemException: String index out of range: -130
Upon further inspection, I see this:
String index out of range: -130
com.intellij.openapi.externalSystem.model.ExternalSystemException: String index out of range: -130
at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:223)
at com.android.tools.idea.gradle.invoker.GradleTasksExecutor.invokeGradleTasks(GradleTasksExecutor.java:400)
at com.android.tools.idea.gradle.invoker.GradleTasksExecutor.run(GradleTasksExecutor.java:221)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:563)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:126)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:400)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)
Any ideas? I've tried with Gradle 2.3 - 2.7 and always get this error building a release build.
build.gradle from main module:
import java.util.regex.Pattern
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
}
}
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
// This does not break the build when Android Studio is missing the JRebel for Android plugin.
apply plugin: 'com.zeroturnaround.jrebel.android'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
signingConfigs {
config {
keyAlias 'XXX'
keyPassword 'XXX'
storeFile file('../signing/keystore.jks')
storePassword 'XXX'
}
}
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.coffeemeetsbagel"
minSdkVersion 16
targetSdkVersion 22
versionCode 605
versionName '2.0.6.0'
signingConfig signingConfigs.config
multiDexEnabled true
}
productFlavors {
lollipop {
minSdkVersion 21
}
everything {
minSdkVersion 16
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
debuggable false
}
debug {
debuggable true
}
superuser.initWith(release)
superuser {
debuggable true
minifyEnabled false
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice'
exclude 'META-INF/notice.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/DEPENDENCIES.txt'
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile files('libs/commons-validator-1.4.1.jar')
compile files('libs/com.kontagent.android.sdk.jar')
compile files('libs/urbanairship-lib-4.0.4.jar')
compile files('libs/apsalar.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.2.3#aar') {
transitive = true
}
compile 'com.github.chrisbanes.photoview:library:1.2.3'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.code.gson:gson:2.3'
compile 'com.google.android.gms:play-services-ads:7.5.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.google.android.gms:play-services-base:7.5.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile 'com.firebase:firebase-client-android:2.2.0'
compile 'com.facebook.shimmer:shimmer:0.1.0#aar'
compile 'com.balysv:material-ripple:1.0.2'
compile 'io.branch.sdk.android:library:1.8.8'
compile 'com.facebook.device.yearclass:yearclass:1.0.1'
compile 'com.appyvet:materialrangebar:1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.adobe.creativesdk:image:4.0.0'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile project(':core')
compile project(':layouts')
compile project(':volley')
}
If you're using Android Studio, selecting the Gradle Console will show you where the problem lies. In my case, it was duplicate textView identifiers that caused this error.
Worked By adding this in build.gradle
lintOptions {
checkReleaseBuilds false
}
My error is
ExternalSystemException: String index out of range:-
My app support Turkish and English language. My English strings.xml contains
<string name="hello_world">Hello world!</string>
and my Turkish strings.xml do not contains
<string name="hello_world">Bla bla!</string>
When i add <string name="hello_world">Bla bla!</string> to Turkish strings.xml file the problem solved.
Note: Please look Android Studio's Gradle Console
I had the same problem with Android Studio 1.4 Build on September 28, 2015
What I did was :
Started a build on the main gradle script - that created a run configuration in the menu.
Edited the run configuration by adding ":app:assembleRelease" on the script parameters row. and started it.
The gradle build showed me that I had missing translations in the main strings.xml file.
After fixing this. Generate Signed APK finished without problem.
I had the same problem but with this error:
ExternalSystemException: String index out of range: -119
My problem was that in the string editor i forgot to set a default variable into my translation, after adding it, the problem was solved.
Hope it helps!
So I reverted back to Android Studio 1.3 and the issue went away.
Although this is an old thread, however the following info might be useful for some people. I was getting a bit different message (but similar, googling for the following message redirects me to this thread.)
Execution failed for task ':app:mergeReleaseResources'.
> String index out of range: 0
For me the problem was the string.xml was missing the name for a string resource as mentioned below.
<string name="">Some strings...</string>
Adding the proper resource name resolved the issue.
<string name="some_string">Some strings...</string>
I have same problem. my Android Studio version is ver2.1.1
My strings.xml contains
<string name="title_connecting">connecting...</string>
then I change to the following statement. the problem solved.
<string name="title_connecting">connecting..</string>

Android app is only running when compiled using older maven repository

I`m working on a project that compiles correctly but crashes on start when I set new maven repository on build.gradle file.
The project is using the lib holoeverywhere, and it crashes with the error: java.lang.NoClassDefFoundError: android.support.v4.app._HoloFragmentInflater$1
Until last month, everything was working fine, but suddenly the older company repository went offline and we created a new one. Now, if I set the older repository on my build.gradle file the app compiles and runs successfully, but if I remove the older repository, it still compiles but when I try to open it crash.
The main problem with that, is that new people trying to compile the code for the first time, using new or older repo, gets the crash on start.
So, I think this can be caused by some cache made by gradle, but looking at the .gradle folder I couldn't find anything.
Can some one help me with that?
Here is the build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
mavenCentral()
maven {
url "http://<new_repository_url>/artifactory/simple/libs-release-local/"
}
// if I remove comment from these lines the project runs correctly
//maven {
//url "https://<old_repository_url>/content/groups/AndroidPublicRepository/"
//}
maven {
url "http://holoeverywhere.cf/repo"
}
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 131
versionName '1.5'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/license.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/NOTICE.txt'
}
android {
lintOptions {
abortOnError false
}
}
productFlavors {
}
}
configurations {
all*.exclude(group: 'org.springframework', module: 'spring-core')
all*.exclude(group: 'org.springframework', module: 'spring-web')
all*.exclude(group: 'org.hamcrest', module: 'hamcrest-core')
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:support-v13:19.1.0'
compile 'org.holoeverywhere:library:2.1.0'
compile 'com.viewpagerindicator:viewpagerindicator:2.4.1'
compile 'com.googlecode.libphonenumber:libphonenumber:5.9'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.4'
compile 'com.google.code.gson:gson:2.3'
compile 'com.octo.android.robospice:robospice:1.4.14'
compile 'com.octo.android.robospice:robospice-cache:1.4.14'
compile 'com.octo.android.robospice:robospice-spring-android:1.4.14'
compile 'org.springframework.social:spring-social-core:1.0.2.PATCHED'
compile('org.springframework.android:spring-android-auth:1.0.1.RELEASE') {
exclude group: 'org.springframework.social', module: 'spring-social-core'
}
compile project(':addon-preferences-2.1.0')
}
I recommend you to remove HoloEverywhere from your app. It was a great library, but it isn't now. It's not very difficult: just change imports, some little adjustments and minSdkVersion = 15. Other option: Material Design.
Anyway, if you can't remove it or you can't do it right now:
HoloEverywhere had a dependency with a patched support-v4. I think the problem is that you don't have this patched version at your maven repository. You can find this code in the branch support-library.

Unable to load class OutputFileTask with Android Studio 1.2 and Gradle 1.2.2

After upgrading to Android Studio 1.2, I´m getting the following error when trying to sync my project
Error:Unable to load class
'com.android.build.gradle.internal.tasks.OutputFileTask'. Possible
causes for this unexpected error include:Gradle's dependency
cache may be corrupt (this sometimes occurs after a network connection
timeout.) Re-download dependencies and sync
project (requires network)The state of a Gradle build
process (daemon) may be corrupt. Stopping all Gradle daemons may solve
this problem. Stop Gradle build processes
(requires restart)In the case of corrupt Gradle
processes, you can also try closing the IDE and then killing all Java
processes.
This is my gradle file
apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'maven-publish'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
repositories {
mavenCentral()
}
defaultConfig {
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
consumerProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile 'com.android.support:support-v4:22.1.0'
compile 'com.android.support:appcompat-v7:22.1.0'
}
task sourceJar(type: Jar) {
classifier "source"
}
publishing {
publications {
repositories.maven {
url repo
credentials {
username user
password passwd
}
}
maven(MavenPublication) {
artifacts {
groupId 'com.android'
artifactId 'artefact-1'
version '1'
artifact artifactPath
}
}
}
}
}
I think there could be yet another gradle api change which is causing the old stuff to not work anymore.
How can I solve the problem to build my project again?
Are you using dexguard? I had the issue with an old dexguard version. Since I updated to 6.1.19 there is no issue anymore. (Currently using AS 1.2.1 & Gradle 2.4 & 1.2.3)
Same problem here. After update Dexguard everything works fine.
Dexguard version 7.0.04
Gradle 2.4
Gradle Plugin 1.2.3

Categories

Resources