11

The docs claim a build.gradle like this works:

android {
  compileSdkVersion 'android-N'
  buildToolsVersion 24.0.0
  ...

  defaultConfig {
     minSdkVersion 'N'
     targetSdkVersion 'N'
     ...
  }
  ...
}

That gives me failed to find Build Tools revision 24.0.0, when using 'com.android.tools.build:gradle:1.5.0' for the Android Plugin for Gradle and Gradle 2.5.

If I look in build-tools/ in my Android SDK installation, I see 24.0.0-preview, not 24.0.0. However, if I switch my build.gradle to use buildToolsVersion "24.0.0-preview", I get Invalid revision: 24.0.0-preview.

So, what combination of build.gradle values works to build a project to compile against the N Developer Preview SDK?

6
  • is your emulator running with N images ? Mine crashes at start up Mar 10, 2016 at 18:04
  • I have the x86 emulator working (I haven't tried the x86_64 one), though I am doing more of my testing on hardware. Mar 10, 2016 at 18:06
  • Why anyone would go for Android N as google have already said that its not a stable version until unless Android N beta released.
    – Pankaj
    Mar 10, 2016 at 18:20
  • @Clairvoyant: Testing your apps on developer previews is fairly important. For example, your app might behave poorly as the user resizes the window using N's multi-window feature. Or, there may be specific things in the new version that you want to start developing now, so that once N ships in final form, you are ready to deploy an updated app (e.g., scoped directory access to give you better options for removable storage). If you want to wait for a later developer preview, that's your call. Mar 10, 2016 at 18:23
  • But the thing is your OS might not work properly and you would think that your code or configuration is not correct. Beta version would give stability to your OS. Preview version is mainly for testing of device for New OS.
    – Pankaj
    Mar 11, 2016 at 5:24

5 Answers 5

4

Based on one of the sample apps, I am now using:

  • Gradle 2.10
  • 'com.android.tools.build:gradle:2.1.0-alpha1' for the Android Plugin for Gradle (goes in your top-level build.gradle file)
  • buildToolsVersion "24.0.0 rc1"

This seems to be holding up, including with Android Studio 1.5.1.

UPDATE: Now that N Developer Preview 4 has been released, we can start using 24 in place of "N" and "android-N":

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        minSdkVersion 24
        targetSdkVersion 24
    }
}
3

I believe issue occurred because of using buildToolsVersion 24.0.0.

According to official set up guide, use:

  compileSdkVersion 'android-N'
  buildToolsVersion '24.0.0 rc1'

  defaultConfig {
    minSdkVersion 'N'
    targetSdkVersion 'N'
    ...
  }

Note that minSdkVersion other than 'N' works as well, but you'll have to use 'N' device to run your app anyways.

Gradle 2.4 works for me. Also you don't have to use 'com.android.tools.build:gradle:2.1.0-alpha1' as it is mentioned in preview samples. Using classpath 'com.android.tools.build:gradle:1.5.0' works as well.

 dependencies {
     classpath 'com.android.tools.build:gradle:1.5.0'
     ...
 }

Don't forget to get the Java 8 JDK and JRE. It is required to make it work on 'N', but you can set sourceCompatibility JavaVersion.VERSION_1_7 and targetCompatibility JavaVersion.VERSION_1_7 if not using Java 8 features.

Note: Using the new Java 8 language features is not a requirement for developing apps that target the Android N platform. If you don't want to write code with Java 8 language features, you can keep your project's source and target compatibility values set to Java 7, but you still must compile with JDK 8 to build against the Android N platform.

Check Java 8 Language Features for details.

1

I seem to be rolling pretty well with this config on a new project with a PixelC:

android {
    compileSdkVersion 'android-N'
    buildToolsVersion '24.0.0 rc4'

    lintOptions {
        abortOnError false
    }


    defaultConfig {
        minSdkVersion 'N'
        targetSdkVersion 'N'

        jackOptions {
            enabled true
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

...
}
0

Based on Sample project you have to use

android {
    compileSdkVersion 'android-N'
    buildToolsVersion '24.0.0 rc1'

    defaultConfig {
        applicationId "com.android.multiwindowplayground"
        minSdkVersion 'N'
        targetSdkVersion 'N'
  ....

    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}
  • Android Studio 2.1 Preview
  • Use gradle-2.10-all.zip
  • com.android.tools.build:gradle:2.1.0-alpha1 for the Android Plugin for Gradle (goes in your top-level build.gradle file)
  • buildToolsVersion "24.0.0 rc1"
  • Select N: Android API 23, N Preview (Preview). Its working for me.
4
0

The problem is that you can not put minSdkVersionless than "N". if you put a smaller version, or receive error, or go only +23 devices.

3
  • Thats not true. I have 8 as min SDK: minSdkVersion 8 targetSdkVersion 'N'
    – Phyrum Tea
    Mar 10, 2016 at 22:29
  • I can make 17 but when I try to install the emulator receive error . 23+ only say . then it may be an error of windows . Mar 10, 2016 at 22:32
  • 1
    that's not quite right. Basically you can use any version for minSdkVersion, but you will still need an "N" device to run the app.
    – Ivan V
    Mar 16, 2016 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.