Android studio with experimental gradle 0.2.0

后端 未结 3 1544
甜味超标
甜味超标 2021-01-19 13:30

I am trying to setup a basic ndk build with the latest version of android studio at this moment. Trying to follow this tutorial

This is my gradle-w

相关标签:
3条回答
  • 2021-01-19 13:47

    @jonagon Some examples are in this repo:
    https://github.com/googlesamples/android-ndk

    probably could try:

    • Use the latest plugin version. Find it at:https://jcenter.bintray.com/com/android/tools/build/gradle-experimental
    • check https://github.com/googlesamples/android-ndk/blob/master/hello-jni/app/build.gradle for product flavors

    jni folder issue:

    1. it is default for gradle experimental plugin, also for older c++ support NOT using gradle-experimental plugin ( android plugin )

    2. if you have that folder and not using experimental plugin, Gradle thinks that app is using the older android studio c++ support. It gives your that warning "NDK integration is deprecated in the current plugin" and recommend you to experimental plugin. it could be silenced with:

      • sourceSets.main.jni.srcDirs = []

    or just rename that jni folder to something else: it will cause more trouble if you want to android-studio cmake/ndk-build in the future, rename is better.

    0 讨论(0)
  • 2021-01-19 13:50

    You have to put these blocks outside the android block.

    android.buildTypes
    android.sources
    android.productFlavors
    

    Also the buildConfigFields.with should be inside the defaultConfig or inside the buildTypes or productFlavors:

    Something like:

    model {
        android {
            compileSdkVersion = 22
            buildToolsVersion = "22.0.1"
    
            defaultConfig.with {
                //----
                minSdkVersion.apiLevel = 10
                targetSdkVersion.apiLevel = 23
    
                buildConfigFields.with {
                    create() {
                        //....
                    }
                }
            }
        }
        android.buildTypes {
            release {
                //
            }
        }
        android.productFlavors {
           //
        }
    
        // Configures source set directory.
        android.sources {
            //
        }
    }
    

    Also, the last version is 0.2.1.

    classpath 'com.android.tools.build:gradle-experimental:0.2.1'
    
    0 讨论(0)
  • 2021-01-19 13:59

    There's a tutorial? Oh, that. Where are the links?

    The current version is 0.2.0.

    or dates?

    I googled every one of the missing files individually (maybe 3 dozen!) after adding:

    classpath 'com.android.tools.build:gradle-experimental:0.2.1'
    

    I tried the alpha version too but I failed finding some of its dependencies altogether.

    First I get a couple of dependencies I can be bothered chasing down:

    > Error:Could not find com.android.tools.build:gradle-experimental:0.2.1.
    Searched in the following locations:
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle-experimental/0.2.1/gradle-experimental-0.2.1.pom
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle-experimental/0.2.1/gradle-experimental-0.2.1.jar
    

    Once each of these was added to the given path seven more would sprout up in its place. If someone could post how to automatically update these (they still aren't in the latest 1.4RC1 Android Studio) it would be very useful. I got most of the stuff from maven, eg http://mvnrepository.com/artifact/com.android.tools.lint/lint-checks/24.3.1

    I got all the files to shut up Gradle's whining and you know what it said?

         Error:(34, 1) A problem occurred evaluating project ':app'.
    > Error: NDK integration is deprecated in the current plugin.  Consider trying the new experimental plugin.  For details, see http://tools.android.com/tech-docs/new-build-system/gradle-experimental.  Set "android.useDeprecatedNdk=true" in gradle.properties to continue using the current NDK integration.
    

    Which was exactly the error that led me to migrate to experimental and no better than the stock 1.3.0 that ships with AS (though it was defaulting to 1.2.3).

    Why did I bother? I want to debug NDK and couldn't see what else I wasn't doing apart from not using an experimental build.

    This goose chase was just a big waste of time. I'm back to using

    android.useDeprecatedNdk=true
    

    No doubt I can fix it somewhere else but just a warning to others chasing experimental dependencies; they are unicorns.

    0 讨论(0)
提交回复
热议问题