Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README should warn that editing gradle properties from Android Studio UI is not supported #61

Closed
2bitProgammer opened this issue Aug 20, 2015 · 12 comments
Labels

Comments

@2bitProgammer
Copy link

This is extremely similar to closed issue #47 , though they didn't say what the fix was. I just did a fresh download of Android Studio 1.3 and downloaded the NDK bundle via AndroidStudio. I have the following installed (amoungst others):

  • Android Support Library 23
  • Android Support Repository 17
  • Ndk Bundle 1
  • Android SDK Tools 24.3.4
  • Android SDK Platform-tools 23
  • Android SDK Build-tools 23
  • Android SDK Build-tools 22.0.1
  • SDK Platform 23 1
  • Google APIs 23 1
  • SDK Platform 22 2
  • Google APIs 21 1

I cloned the samples repo from github and tried to build it. I get the following error:

Error:(16, 0) Gradle DSL method not found: 'android()'
Possible causes:<ul><li>The project 'Teapot' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

My build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.2.0'
    }
}
allprojects {
    repositories {
        jcenter()
    }
}

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}
dependencies {
}

My gradle-wrapper.properties

#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-bin.zip
@ggfan
Copy link
Contributor

ggfan commented Aug 20, 2015

it seems you are still using the previous version of gradle plugin; the new one uses "model". May you check you check whether your local downloaded .../teapot/build.gradle looks like this one:
https://github.com/googlesamples/android-ndk/blob/master/Teapot/build.gradle

and your module build.gradle at .../teapot/app/build.gradle looks like this one:
https://github.com/googlesamples/android-ndk/blob/master/Teapot/app/build.gradle
note: if you see
apply plugin: 'com.android.model.application'
that would be good. your pasted code does not seem to be same as the code in github. please check it out and update your finding, we could continue to investigate

@2bitProgammer
Copy link
Author

Hmmm, so apparently those changes happened when I went to Open Model Settings > Properties and set any of the properties. I had initially changed the properties because I only downloaded buildtools 23 and it was looking for 22.0.1. I downloaded 22.0.1 and then went in the dialog to change it and it must have added those fields. Now I'm getting the error about bad magic numbers (issue #58) which I was able to fix using the posted solution. Note, however, that if I use the F4 Properties dialog to set the versions to 1.7, it does so by adding the code block

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

@ggfan
Copy link
Contributor

ggfan commented Aug 20, 2015

Here is my steps for the samples:

  1. download and install android studio review version at http://tools.android.com/download
  2. get sample code: git clone https://github.com/googlesamples/android-ndk.git
  3. start up android studio, open existing project, navigate into the Teapot directory and open it; you might be asked to find the location of your sdk and ndk, config them; Android studio will automatically sync your project and complains about your NDK location, you would click on the error message and set it up
  4. Sync the project, again you will configure the ndk location if you were not asked in above steps [ or you could put into your local.properties]
  5. build the project and download to your device to run via USB [maybe emulator too, but openGL thing might give your better experience when you are on real device ]

during the process, normally I do not need to change anything else.
May you check against with your procedure? Maybe you are on Windows, the procedure should be similar if not the same. Please update your findings so we could continue to find out what is wrong

@ggfan
Copy link
Contributor

ggfan commented Aug 20, 2015

Oh, since you are using the Java 8, you need to add the
compileOptions.with {
sourceCompatibility=JavaVersion.VERSION_1_7
targetCompatibility=JavaVersion.VERSION_1_7
}
in the module build.gradle inside android section, and android section is inside the model section.

@proppy
Copy link
Contributor

proppy commented Aug 20, 2015

Happy to continue to discussion in #43. We should update the README.md with instruction on how to set JDK 1.7 and/or add the proper build.gradle workaround.

@proppy proppy closed this as completed Aug 20, 2015
@proppy
Copy link
Contributor

proppy commented Aug 20, 2015

reopening this, since we need to clear up why Android Studio made incompatible change to your app build.gradle and escalate to b.android.com.

Sorry for the noise.

@proppy proppy reopened this Aug 20, 2015
@proppy
Copy link
Contributor

proppy commented Aug 21, 2015

Can you try out with "Android Studio 1.3.1"? I don't see the Open Module Settings item anymore when I right click on the app module gradle file.

@proppy
Copy link
Contributor

proppy commented Aug 21, 2015

OK, managed to reproduce it with Build / Edit Build Types ... / Properties / Compile SDK Version.

It will insert:

android {
    compileSdkVersion 21
}
dependencies {
}

Using the old DSL syntax, we should update the README.md to call this out, and get a bug filed on bug.android.com.

@proppy proppy changed the title Error:(16, 0) Gradle DSL method not found: 'android()' Warn in README that editing gradle properties from Android Studio UI is not supported Aug 21, 2015
@proppy
Copy link
Contributor

proppy commented Aug 21, 2015

Updated this issue to track this.

@proppy
Copy link
Contributor

proppy commented Aug 21, 2015

@proppy proppy changed the title Warn in README that editing gradle properties from Android Studio UI is not supported README should warn that editing gradle properties from Android Studio UI is not supported Aug 21, 2015
@ggfan
Copy link
Contributor

ggfan commented May 5, 2016

created a pull request:
#191

since we have a bug tracking it, and it will not be enabled for a while, I like to close this one for now. please let me know your thought, thanks

@ggfan
Copy link
Contributor

ggfan commented May 7, 2016

closing this w/o a proper fix. feel free to re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants