1

After not having the project for one of my apps open for about half a year, I'm unable to start the project, due to NoClassDefFoundError on startup of the app. The last time i had the project opened, everything went fine. The app builds seemingly fine, without any exceptions. Android Studio doesn't show me any errors inside the source (no red underlines of any files or on any rows of the files - I've opened them all, just in case). If i press ctrl+b on an R.array.xyz element, android studio opens the string file with the element.

And yet when accessing a R.array field, i get a:

java.lang.RuntimeException: An error occured while executing doInBackground()
  at android.os.AsyncTask$3.done(AsyncTask.java:278)
  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
  at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NoClassDefFoundError: com.abc.xyz.R$array
  at com.myapp.aClass.createContainerList(aClass.java:323)

where the command is:

        String[] Fehlerklassen = context.getResources().getStringArray(R.array.someStrArray);

and the import is:

import com.myapp.moduleOfClass.R; 

Again: Android Studio says everything is fine. If i use auto complete on for example R.array., it offers me the correct arrays

Removing every access to R.array, the same error comes for R.drawable. Meanwhile Android Studio shows a thumbnail of the correct image in the text editor.

build.gradle file of the module in question:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    compileOptions.encoding = 'windows-1252'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile project(':aModuleThatWorksFineInAnotherProject1')
    compile project(':aModuleThatWorksFineInAnotherProject2')
    compile project(':aModuleThatWorksFineInAnotherProject3')
    compile project(':aModuleThatWorksFineInAnotherProject4')
}

The gradle Console contains only two red messages, after building the app. Both are probably not in fault.

The first also gets shown in another app, which works fine:

AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"}
AGPBI: {"kind":"SIMPLE","text":"(org.ksoap2.transport.KeepAliveHttpsTransportSE$1) that doesn\u0027t come with an","position":{},"original":"(org.ksoap2.transport.KeepAliveHttpsTransportSE$1) that doesn\u0027t come with an"}
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"}
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"}
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"}
AGPBI: {"kind":"SIMPLE","text":"and without specifying any \"-target\" type options. The consequence of ignoring","position":{},"original":"and without specifying any \"-target\" type options. The consequence of ignoring"}
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"}
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."}

and the second one is according to other stackoverflow threads not really an error, but more off a picky output. For a handfull of my images i get:

AAPT err(1171159410): C:\Users\myName\AndroidStudioProjects\myproject\someName\build\intermediates\bundles\debug\res\drawable-mdpi\edit_query.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
CAA
  • 968
  • 10
  • 27

1 Answers1

0

The solution was to extent MultiDexApplication instead of Application in addition to set multidexenabled true. See https://stackoverflow.com/a/30266339/1171328 for more information.

Community
  • 1
  • 1
CAA
  • 968
  • 10
  • 27