NDK Debuggen mit dem gradle-experimental Plugin

Ich versuche, natives Debugging zu einem Projekt hinzuzufügen, das ein Android Studio NDK-Projekt ist. In der Vergangenheit habe ich gradle verwendet, um ein Shell-Skript zu starten, das die NDK-Bibliothek erstellt hat. Jetzt versuche ich, das gradle-experimental-Plugin zu verwenden.

Ich habe das Netz nach den wenigen Informationen durchsucht (meistens hier, Android Tools Site - Gradle Experimental) über die Verwendung von gradle-experimental mit dem NDK und ich habe diese build.gradle-Datei zusammengestellt, die die Vorschau-NDK-Unterstützung verwendet, um den NDK-Build inline mit dem Java-Build auszuführen.

Nachdem ich dies endlich aus einzelnen Informationen zusammengestellt hatte, gelang es mir, den NDK-Teil zu erstellen, aber jetzt ist die Datei httpmime-4.4-beta1.jar nicht mehr enthalten, die eindeutig in den Abhängigkeiten enthalten ist, und ich ' habe viele verschiedene permutationen davon ausprobiert wie in:

compile files("libs/httpmime-4.4.jar")

Aber trotzdem werden die Fehler für die fehlenden Symbole aus der Jar-Datei weiterhin angezeigt.

build.gradle source

    apply plugin: 'com.android.model.application'

    String APP_PACKAGE_NAME = 'com.obfuscated.app',
           VERSION_NAME = '3.0',
           TOOLS_VERSION = '23.0.2'

    int VERSION_CODE = 15,
        MIN_SDK_VERSION = 13,
        TARGET_SDK_VERSION = 19,
        COMPILE_SDK_VERSION = 23

    model {
        repositories {
            libs(PrebuiltLibraries) {
                // prebuilt binaries mirroring Android.mk
                libstuff {
                    headers.srcDirs.add(file("jni/stuff/include/stuff"))
                    binaries.withType(SharedLibraryBinary) {
                        sharedLibraryFile = file("jni/stuff/lib/libstuff.so")
                    }
                }
                // ...several more of these actually exist in build.gradle and are working
                cares {
                    headers.srcDirs.add(file("jni/c-ares/include"))
                    binaries.withType(SharedLibraryBinary) { 
                        // StaticLibraryBinary and staticLibraryFile doesnt work despite sample code, at least not for com.android.tools.build:gradle-experimental:0.6.0-alpha5, this builds even though its a static-lib
                        sharedLibraryFile = file("jni/c-ares/lib/libcaresARM.a")
                    }
                }
            }
        }
        android {
            compileSdkVersion = COMPILE_SDK_VERSION
            buildToolsVersion = TOOLS_VERSION

            defaultConfig.with {
                applicationId = APP_PACKAGE_NAME
                minSdkVersion.apiLevel = MIN_SDK_VERSION
                targetSdkVersion.apiLevel = TARGET_SDK_VERSION
                versionCode = VERSION_CODE
                versionName = VERSION_NAME

                buildConfigFields {
                    create() {
                        type "int"
                        name "VALUE"
                        value "1"
                    }
                }

                compileOptions.with {
                    sourceCompatibility = JavaVersion.VERSION_1_7
                    targetCompatibility = JavaVersion.VERSION_1_7
                }
            }

            signingConfigs {
                create("appRelease") {
                    storeFile file('sign.jks')
                    storePassword '...'
                    keyAlias '...'
                    keyPassword '...'
                    storeType "jks"
                }
            }
        } // end android

        android.lintOptions {
            abortOnError = false
        }

        android.packagingOptions {
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/services/javax.annotation.processing.Processor'
        }

        android.ndk {
            moduleName = "native"
            toolchain "clang"
            toolchainVersion "3.5"
            platformVersion = MIN_SDK_VERSION

            ldLibs.addAll('atomic', 'android', 'log', 'OpenSLES')
            abiFilters.addAll(["armeabi", "armeabi-v7a"])
            CFlags.addAll(["-mfloat-abi=softfp", "-mfpu=neon", "-O3", "-DCARES_STATICLIB", "-Wno-c++11-long-long"])
            cppFlags.addAll(["-I${file("jni")}".toString(),
                             "-I${file("jni/c-ares/include")}".toString(),
                             "-I${file("jni/coffeecatch")}".toString()])
            stl = "stlport_shared"
        }

        android.sources {
            main {
                jniLibs {
                    dependencies {

                    }
                }
                jni {
                    dependencies {
                        library "libstuff"
                        library "cares"
                        // ... 
                    }
                    source {
                        srcDir "jni"
                    }
                }
                // java {
                    // dependencies {
                    //     compile files("libs/httpmime-4.4-beta1.jar")
                    //     compile files("libs/FlurryAnalytics-5.1.0.jar")
                    // }
                // }
            }
        }

        android.buildTypes {
            debug {
                ndk.with {
                    debuggable = true
                }
            }
            release {
                minifyEnabled = false
                ndk.with {
                    debuggable = true
                }
            }
        }

        android.productFlavors {
            create("arm") {
                ndk.with {
                    abiFilters.add("armeabi-v7a")

                    ldLibs.addAll([file("jni/stuff/lib/libstuff.so").toString(),
                                            file("jni/c-ares/lib/libcaresARM.a").toString()])
                }
            }
            create("fat") {
                // compile and package all supported ABI
            }
        }

    } // end model

    repositories {
        mavenCentral()
    }

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

        compile 'com.android.support:support-v4:23.+'
        compile 'com.android.support:appcompat-v7:23.+'
        compile 'com.android.support:support-v13:23.+'
        compile 'com.android.support:support-annotations:23.+'

        compile 'com.squareup:otto:1.3.8'
        compile 'com.github.machinarius:preferencefragment:0.1.1'
        compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
        compile 'com.fasterxml.jackson.core:jackson-core:2.5.+'
        compile 'com.fasterxml.jackson.core:jackson-annotations:2.5.+'
        compile 'com.fasterxml.jackson.core:jackson-databind:2.5.+'

        compile 'com.jakewharton:butterknife:7.0.1'
        compile 'com.google.guava:guava:19.0'
    }


    allprojects {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
        }
    }

Out of Frustration wechselte ich zurück zum nicht experimentellen Zweig, und selbst mit der alten build.gradle-Datei kann diese JAR-Datei jetzt nicht mehr gefunden werden. Handelt es sich also um ein Problem mit Android Studio 2.0 Preview 6?

Hat jemand anderes dies erlebt oder eine Lösung dafür? Es wäre so bequem, NDK-Debugging direkt in Android Studio zu haben, und wenn es diese letzte Hürde nicht gäbe, würde ich da sein.

Short der Neuschreibung des Codes, der von dieser JAR-Datei abhängt, bin ich ratlos, was ich sonst noch versuchen kann. Ich bin auch offen für Vorschläge zum Format meiner build.gradle-Datei, da die Dokumentation für diese neuen Funktionen noch sehr spärlich ist und einige Beispiele hinsichtlich der richtigen Syntax bereits veraltet zu sein scheinen.

WAS VERMISSE ICH

Sie können sehen, dass das C und das Cpp (mobil: compileNativeArmeabiDebugArmSharedLibraryNativeMainCpp) Schritte ausführen, aber dann schlägt der Javac fehl. Dieser Ansatz für JAR-Dateien hat sich in den letzten 2 Jahren für die http-mime lib von Apache bewährt, daher verstehe ich nicht, warum dies plötzlich ein Problem ist.

    :mobile:mergeArmDebugAndroidTestAssets
    :mobile:generateArmDebugAndroidTestResValues UP-TO-DATE
    :mobile:generateArmDebugAndroidTestResources
    :mobile:mergeArmDebugAndroidTestResources
    :mobile:processArmDebugAndroidTestResources
    :mobile:generateArmDebugAndroidTestSources
    :mobile:copyArmeabi-v7aDebugArmSharedLibraryStlSo
    :mobile:compileNativeArmeabi-v7aDebugArmSharedLibraryNativeMainC
    :mobile:compileNativeArmeabi-v7aDebugArmSharedLibraryNativeMainCpp
    :mobile:linkNativeArmeabi-v7aDebugArmSharedLibrary
    :mobile:nativeArmeabi-v7aDebugArmSharedLibrary
    :mobile:stripSymbolsArmeabi-v7aDebugArmSharedLibrary
    :mobile:ndkBuildArmeabi-v7aDebugArmSharedLibrary
    :mobile:ndkBuildArmeabi-v7aDebugArmStaticLibrary UP-TO-DATE
    :mobile:copyArmeabiDebugArmSharedLibraryStlSo
    :mobile:compileNativeArmeabiDebugArmSharedLibraryNativeMainC
    :mobile:compileNativeArmeabiDebugArmSharedLibraryNativeMainCpp
    :mobile:linkNativeArmeabiDebugArmSharedLibrary
    :mobile:nativeArmeabiDebugArmSharedLibrary
    :mobile:stripSymbolsArmeabiDebugArmSharedLibrary
    :mobile:ndkBuildArmeabiDebugArmSharedLibrary
    :mobile:ndkBuildArmeabiDebugArmStaticLibrary UP-TO-DATE
    :mobile:processAndroidArmDebugMainJniLibs UP-TO-DATE
    :mobile:androidArmDebug
    :mobile:compileArmDebugJavaWithJavac
    :mobile:compileArmDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).

Ja, ich weiß, dass die Apache-Bibliotheken veraltet sind, aber dies ist Legacy-Code, der trotz dieser Tatsache funktionieren sollte und in Zukunft aktualisiert wird.

Antworten auf die Frage(2)

Ihre Antwort auf die Frage