I have downloaded new Android Studio 2.1 and upgraded my openJDK to version 8.
But I have this issue :
What have I done wrong and what should I do?
Thanks!
added gradl
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:24.0.0-alpha2'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:cardview-v7:23.3.0'
compile files('libs/svgandroid.jar')
compile 'com.android.support:design:23.3.0'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile files('libs/guava-16.0.1.jar')
compile 'com.google.code.gson:gson:2.6.1'
}
// The sample build uses multiple directories to
// keep boilerplate and common code separate from
// the main sample code.
List<String> dirs = [
'main', // main sample code; look here for the interesting stuff.
'common', // components that are reused by multiple samples
'template'] // boilerplate code that is generated by the sample template process
android {
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
repositories {
mavenCentral()
}
defaultConfig {
minSdkVersion 21
targetSdkVersion 21
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
dirs.each { dir ->
java.srcDirs "src/${dir}/java"
res.srcDirs "src/${dir}/res"
}
}
androidTest.setRoot('tests')
androidTest.java.srcDirs = ['tests/src']
}
}
See the documentation: http://tools.android.com/tech-docs/configuration/osx-jdk
It involves setting a $STUDIO_JDK environment variable.
Related
I'm trying to implement this approach - https://www.androidsecurity.info/2016/12/15/storing-your-secure-information-in-the-ndk/.
The moment when I add cmake path in a gradle file,
externalNativeBuild {
cmake {
path 'src/CMakeLists.txt'
}
}
building process stuck with StackOverflowError.
_
Note. If I implement that approach in a new project, everything works fine - gradle builds successfully, and native method works in java class. The problem occurs when I do the same on my "production" project with many dependencies.
As you can see gradle stuck on "resolve artifact uiautomator-v18.aar". When remove "uiautomator" from dependencies, same error appears but with "espresso-core", remove "espresso-core" - "hamcrest-library" is the next, and so on.
All module build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'kotlin-android-extensions'
androidExtensions {
experimental = true
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
repositories {
jcenter()
}
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'io.fabric.tools:gradle:1.21.4'
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
android {
lintOptions {
// google services plugin is causing missing translation issue
abortOnError false
disable 'MissingTranslation'
}
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.toolsVersion
signingConfigs { ... }
defaultConfig {
applicationId "..."
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
buildConfigField "boolean", "USE_ANALYTIC", "false"
buildConfigField 'boolean', 'USE_TRANSLATION', 'false'
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "USE_ANALYTIC", "true"
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
debuggable true
buildConfigField "boolean", "USE_ANALYTIC", "false"
}
}
productFlavors {...}
externalNativeBuild {
cmake {
path 'src/CMakeLists.txt'
}
}
dataBinding { enabled = true }
}
configurations { ... }
dependencies {
...
// debug tools
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile rootProject.deps.firebaseMessaging
compile rootProject.deps.firebaseCore
compile rootProject.deps.firebaseConfig
compile 'com.squareup.picasso:picasso:2.5.2'
compile('com.mcxiaoke.viewpagerindicator:library:2.4.1') {
exclude module: 'support-v4';
}
compile "com.android.support:support-vector-drawable:$supportLibrary"
compile "com.android.support:animated-vector-drawable:$supportLibrary"
compile rootProject.deps.appCompat
compile rootProject.deps.cardView
compile rootProject.deps.design
compile project(':sublimepickerlibrary')
compile project(':segmentedcontrol')
compile project(':stickyheaderlist')
compile "com.android.support:customtabs:$supportLibrary"
apt rootProject.deps.daggerCompiler
testCompile rootProject.testDeps.junit
testCompile rootProject.testDeps.intellijannotations
testCompile rootProject.testDeps.mockito
testCompile rootProject.testDeps.mockitoKotlin
androidTestCompile "com.android.support:support-annotations:$supportLibrary"
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.artemzin.rxjava:proguard-rules:1.0.14.2'
compile rootProject.deps.rxAndroid
compile rootProject.deps.rxJava
}
configurations.all {
resolutionStrategy {
force "org.mockito:mockito-core:$mockito",
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.google.gms.google-services'
Appreciate any help - either direct answer or at least point out where to research.
I am using BetterSpinner in my app.
I have simply included it like that:
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
When I try to use it Android Studio even does not suggest to import the library and marks BetterSpinner red:
The code:
BetterSpinner textView = (BetterSpinner)
findViewById(R.id.registration_spinner_stufe);
textView.setAdapter(adapter);
Where is the mistake that Android Studio does not import the BetterSpinner library into my Fragment class?
The solution
"File" -> "Invalidate Caches..." -> "Invalidate and Restart"
did not work for me..
import com.weiwangcn.betterspinner.library.BetterSpinner;
import com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner;
Was ignored by Android Studio:
My complete grade file:
[app]
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.example.jublikon"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main { res.srcDirs = ['src/main/res', 'src/main/res/drawable/ic_action_search.png'] }
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//Google Libraries
compile 'com.android.support:appcompat-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.github.navasmdc:MaterialDesign:1.5#aar'
compile 'com.github.rey5137:material:1.2.1.6-SNAPSHOT'
compile 'com.github.paolorotolo:appintro:3.3.0'
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
}
[project]
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
mavenCentral()
}
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
I want to add SimpleCropView to my Android Project from Github https://github.com/IsseiAoki/SimpleCropView but dont know how to proceed.My Project Gradle file are as follows.
Project 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:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Module Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "loginscreen.example.com.girviapp"
minSdkVersion 12
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:design:22.2.0'
compile files('libs/dropbox-android-sdk-1.6.3/dropbox-android-sdk-1.6.3.jar')
compile files('libs/dropbox-android-sdk-1.6.3/json_simple-1.1.jar')
compile files('libs/jcifs-1.3.18.jar')
}
Include the following dependency in your build.gradle file.
dependencies {
compile 'com.isseiaoki:simplecropview:1.0.8'
}
I'm using Robospock to perform unit testing and mocking with gradle. This worked great until I added gradle build variants to the mix.
My android build.gradle file:
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName "0.0.1"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
uat {
packageName "com.acme.dev"
}
stage {
packageName "com.acme.staging"
}
prod {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.mcxiaoke.volley:library:1.0.4'
}
My robospock build.gradle file:
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
classpath 'org.robospock:robospock-plugin:0.4.0'
}
}
repositories {
mavenCentral()
}
apply plugin: 'groovy'
dependencies {
compile "org.codehaus.groovy:groovy-all:1.8.6"
compile 'org.robospock:robospock:0.4.4'
compile 'cglib:cglib-nodep:2.2'
compile 'org.objenesis:objenesis:1.3'
}
project.ext {
robospock = ":Mothership" // project to test
}
apply plugin: 'robospock'
The Android gradle plug-in offers me build variant tasks such as assembleProd, assembleProdDebug, assembleStageDebugTest. Can I pass something to Robospocl in my build.gradle so that it can participate in the build variants?
Currently when I execute ./gradlew robospok, it cannot find the classes defined in com.acme.dev or com.acme.staging
I'm trying to use gradle to build my Android project wit Android Annotations but I still get errors. In my java classes AA is not found.
Also in gradle file I get some hints:
versionName "1.0" <- 'versionName' cannot be applied to '(java.lang.String)'
'main' in 'build' cannot be applied to '(groovy.lang.Closure)'
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', 'GENERATED_FOLDER']
resources.srcDirs = ['src/main/resources']
res.srcDirs = ['src/main/res']
assets.srcDirs = ['src/main/assets']
}
Below is my full gradle script:
buildscript {
repositories {
mavenCentral()
}
dependencies {
// replace with the current version of the Android plugin
classpath 'com.android.tools.build:gradle:0.9.2'
// the latest version of the android-apt plugin
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.1'
}
}
repositories {
mavenCentral()
mavenLocal()
}
apply plugin: 'android'
apply plugin: 'android-apt'
def AAVersion = '3.0.1'
dependencies {
// Android annotations
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'com.android.support:appcompat-v7:19.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
// ORMLite
compile 'com.j256.ormlite:ormlite-android:4.46'
// Google Guava
compile 'com.google.guava:guava:16.0.1'
}
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName 'pl.grzeslowski.weaselmoney'
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', 'GENERATED_FOLDER']
resources.srcDirs = ['src/main/resources']
res.srcDirs = ['src/main/res']
assets.srcDirs = ['src/main/assets']
}
}
}
This is log from my console in Android Studio:
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:weasel_moneyWeaselMoney:help
Welcome to Gradle 1.10.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
BUILD SUCCESSFUL
Total time: 6.111 secs
Process finished with exit code 0
Dont put your AA configuration on your General build.gradle
put it in your app folder inside build.gradle, look # this example
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = '3.2'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName 'com.example.app'
logLevel 'TRACE' //Use this to get AA log
logAppenderConsole 'true' //Use this to get AA log
}
}
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
debug {
debuggable true
}
}
packagingOptions {
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
}
}
dependencies {
//Libs
compile fileTree(dir: 'libs', include: ['*.jar'])
//Dependency
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M1' //If you're using REST
compile 'com.google.code.gson:gson:1.7.2'
compile 'org.codepond:wizardroid:1.3.0'
//Android Annotations
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}