1

Ich versuche RecyclerView zu einem Projekt hinzuzufügen, das ich geerbt habe, das gegen API 19 kompiliert wurde und nicht höher gehen kann.Kann RecyclerView nicht zu API Level 19 hinzufügen

Nachdem ich hinzufügen RecylerView von der Support-Bibliothek wie folgt aus:

compile 'com.android.support:recyclerview-v7:+' 

Das Projekt nicht mehr bauen, beginnt es multidex Ausnahmefehler wie diese geben:

Error:Execution failed for task ':app:transformClassesWithDexForDevDebug'. 
> 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_91\bin\java.exe'' finished with non-zero exit value 3 

dieses Problem zu beheben, ich habe folgendes getan

  1. Aktivierte multidex unterstützung wie so multiDexEnabled true
  2. hinzufügen compile 'com.android.support:multidex:1.0.1'
  3. Installieren multidex in applciation Klasse wie folgt: MultiDex.install(this);

All dies half nicht. Hier ist die Abhängigkeiten Grafik von laufenden ./gradlew App: Abhängigkeiten

Und basierend auf der Grafik unten, welche Änderung muss ich machen, um das Projekt wieder aufzubauen? Hier

compile - Classpath for compiling the main sources. 
+--- com.android.support:multidex:1.0.1 
+--- org.simpleframework:simple-xml:2.7.1 
| \--- stax:stax:1.2.0 
+--- com.squareup.retrofit2:converter-simplexml:2.0.0-beta3 
| +--- com.squareup.retrofit2:retrofit:2.0.0-beta3 
| | \--- com.squareup.okhttp3:okhttp:3.0.0-RC1 
| |   \--- com.squareup.okio:okio:1.6.0 
| \--- org.simpleframework:simple-xml:2.7.1 (*) 
+--- com.crashlytics.sdk.android:crashlytics:2.5.5 
| +--- com.crashlytics.sdk.android:answers:1.3.6 
| | \--- io.fabric.sdk.android:fabric:1.3.10 
| +--- com.crashlytics.sdk.android:crashlytics-core:2.3.8 
| | +--- com.crashlytics.sdk.android:answers:1.3.6 (*) 
| | \--- io.fabric.sdk.android:fabric:1.3.10 
| +--- io.fabric.sdk.android:fabric:1.3.10 
| \--- com.crashlytics.sdk.android:beta:1.1.4 
+--- com.crashlytics.sdk.android:crashlytics-ndk:1.1.2 
| +--- io.fabric.sdk.android:fabric:1.3.7 -> 1.3.10 
| \--- com.crashlytics.sdk.android:crashlytics-core:2.3.5 -> 2.3.8 (*) 
+--- commons-net:commons-net:3.3 
+--- com.github.danysantiago:sendgrid-android:1 
| +--- org.apache.httpcomponents:httpmime:4.3.5 
| | \--- org.apache.httpcomponents:httpclient:4.3.5 
| |   +--- org.apache.httpcomponents:httpcore:4.3.2 
| |   +--- commons-logging:commons-logging:1.1.3 
| |   \--- commons-codec:commons-codec:1.6 
| \--- org.apache.httpcomponents:httpclient-android:4.3.5.1 
+--- com.amazonaws:aws-android-sdk-core:2.2.11 
| \--- com.google.code.gson:gson:2.2.4 
+--- com.amazonaws:aws-android-sdk-s3:2.2.11 
| \--- com.amazonaws:aws-android-sdk-core:2.2.11 (*) 
+--- com.google.code.ksoap2-android:ksoap2-android:3.6.0 
| \--- com.google.code.ksoap2-android:ksoap2-j2se:3.6.0 
|   \--- com.google.code.ksoap2-android:ksoap2-base:3.6.0 
|    +--- net.sourceforge.kxml:kxml:2.2.4 
|    | \--- org.xmlpull:xmlpull:1.1.3.3 
|    \--- net.sourceforge.kobjects:kobjects-j2me:0.0-SNAPSHOT-20040926-2 
+--- com.squareup.retrofit2:retrofit:2.0.0-beta3 (*) 
\--- com.android.support:recyclerview-v7:+ -> 24.1.1 
    +--- com.android.support:support-v4:24.1.1 
    | \--- com.android.support:support-annotations:24.1.1 
    \--- com.android.support:support-annotations:24.1.1 

ist die komplette Gradle Ausgabe https://dl.dropboxusercontent.com/u/15447938/gradle_output.txt

Dies ist die komplette Build-Ausgabe

Information:Gradle tasks [:app:assembleDevDebug] 
Warning:Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for prodDebug as it may be conflicting with the internal version provided by Android. 
     In case of problem, please repackage it with jarjar to change the class packages 
Warning:Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for prodRelease as it may be conflicting with the internal version provided by Android. 
     In case of problem, please repackage it with jarjar to change the class packages 
Warning:Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for devDebug as it may be conflicting with the internal version provided by Android. 
     In case of problem, please repackage it with jarjar to change the class packages 
Warning:Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for devRelease as it may be conflicting with the internal version provided by Android. 
     In case of problem, please repackage it with jarjar to change the class packages 
:app:preBuild UP-TO-DATE 
:app:preDevDebugBuild UP-TO-DATE 
:app:checkDevDebugManifest 
:app:preDevReleaseBuild UP-TO-DATE 
:app:preProdDebugBuild UP-TO-DATE 
:app:preProdReleaseBuild UP-TO-DATE 
:app:prepareComAndroidSupportRecyclerviewV72411Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportV42411Library UP-TO-DATE 
:app:prepareComCrashlyticsSdkAndroidAnswers136Library UP-TO-DATE 
:app:prepareComCrashlyticsSdkAndroidBeta114Library UP-TO-DATE 
:app:prepareComCrashlyticsSdkAndroidCrashlytics255Library UP-TO-DATE 
:app:prepareComCrashlyticsSdkAndroidCrashlyticsCore238Library UP-TO-DATE 
:app:prepareComCrashlyticsSdkAndroidCrashlyticsNdk112Library UP-TO-DATE 
:app:prepareComGithubDanysantiagoSendgridAndroid1Library UP-TO-DATE 
:app:prepareIoFabricSdkAndroidFabric1310Library UP-TO-DATE 
:app:prepareDevDebugDependencies 
:app:compileDevDebugAidl UP-TO-DATE 
:app:compileDevDebugRenderscript UP-TO-DATE 
:app:generateDevDebugBuildConfig UP-TO-DATE 
:app:generateDevDebugAssets UP-TO-DATE 
:app:mergeDevDebugAssets UP-TO-DATE 
:app:processDevDebugManifest UP-TO-DATE 
:app:fabricGenerateResourcesDevDebug 
:app:generateDevDebugResValues UP-TO-DATE 
:app:generateDevDebugResources 
:app:mergeDevDebugResources 
:app:processDevDebugResources 
:app:generateDevDebugSources 
:app:compileDevDebugJavaWithJavac 
Note: Some input files use or override a deprecated API. 
Note: Recompile with -Xlint:deprecation for details. 
Note: Some input files use unchecked or unsafe operations. 
Note: Recompile with -Xlint:unchecked for details. 
:app:compileDevDebugNdk 
:app:compileDevDebugSources 
:app:transformClassesWithDexForDevDebug 
Warning:Ignoring InnerClasses attribute for an anonymous inner class 
(com.bea.xml.stream.util.CircularQueue$1) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
UNEXPECTED TOP-LEVEL EXCEPTION: 
Error:Execution failed for task ':app:transformClassesWithDexForDevDebug'. 
> 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_91\bin\java.exe'' finished with non-zero exit value 2 
Information:BUILD FAILED 
Information:Total time: 1 mins 10.137 secs 
Information:1 error 
Information:5 warnings 
Information:See complete output in console 
+0

Ich glaube nicht, dass Gradle Fehler explizit auf MultiDex bezogen wird, da das Hinzufügen von MultiDex anscheinend nicht geholfen hat –

+0

Ja, ich werde die Multidex entfernen. Aber das Projekt baut immer noch nicht auf –

+0

Können Sie bitte mehr von der Gradle-Ausgabe als nur die Ausnahme hinzufügen? –

Antwort

1

Da Sie hinzufügen:

compile 'com.android.support:recyclerview-v7:+' 

Sie die 24.1.1 Version verwenden.
Die Supportbibliotheken v24 erfordern, dass API 24 kompiliert wird.

android { 
    compileSdkVersion 24 
    //... 

} 

können Sie another version des RecyclerView verwenden, aber die erste Version war 21.0.0 die API21 erfordert.

1

Kann bauen und führen dies auf API 19 Gerät ohne Probleme und haben viele Ansichten mit RecyclerView.

Nimm davon was du willst. Wenn es nicht hilft, sorry.

build.gradle

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "24.0.1" 

    defaultConfig { 
     applicationId "com.androidstack.app" 
     minSdkVersion 16 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
//  generatedDensities = [] 
    } 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_7 
     targetCompatibility JavaVersion.VERSION_1_7 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    // This is handled for you by the 2.0+ Gradle Plugin 
    aaptOptions { 
     additionalParameters "--no-version-vectors" 
    } 
} 

ext { 
    // Variables to keep libraries consistent 
    supportLibrary = '23+' 

    // Support Libraries dependencies 
    supportDependencies = [ 
      design   :   "com.android.support:design:${supportLibrary}", 
      recyclerView  :   "com.android.support:recyclerview-v7:${supportLibrary}", 
      appCompatV7  :   "com.android.support:appcompat-v7:${supportLibrary}", 
    ] 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 

    // compile supportDependencies.recyclerView 

    // recommended instead - Includes themes, AppCompat libraries, and RecyclerView 
    compile supportDependencies.design 

} 

Abhängigkeitsbaum

+--- com.android.support:design:23+ -> 23.4.0 
    +--- com.android.support:recyclerview-v7:23.4.0 
    | +--- com.android.support:support-annotations:23.4.0 
    | \--- com.android.support:support-v4:23.4.0 
    |   \--- com.android.support:support-annotations:23.4.0 
    +--- com.android.support:appcompat-v7:23.4.0 
    | +--- com.android.support:animated-vector-drawable:23.4.0 
    | | \--- com.android.support:support-vector-drawable:23.4.0 
    | |   \--- com.android.support:support-v4:23.4.0 (*) 
    | +--- com.android.support:support-v4:23.4.0 (*) 
    | \--- com.android.support:support-vector-drawable:23.4.0 (*) 
    \--- com.android.support:support-v4:23.4.0 (*)