Today downloaded the studio 3.0 beta 2.0 version, after that tried to open an existing project in it and faced some difficulties, most of them I could solve with the help of Google and Stack Overflow, but this one I can not.
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: org.gradle.tooling.BuildException: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Also posting my app gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.intersoft.snappy"
minSdkVersion 19
targetSdkVersion 22
multiDexEnabled true
versionCode 1
versionName "1.0"
}
buildTypeMatching 'dev', 'debug'
buildTypeMatching 'qa', 'debug'
buildTypeMatching 'rc', 'release'
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/']
} }
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
maven { url "https://jitpack.io" }
maven { url 'https://dl.bintray.com/ashokslsk/CheckableView' }
maven { url "https://maven.google.com" }
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.github.mrengineer13:snackbar:1.2.0'
implementation 'com.android.support:recyclerview-v7:26.0.1'
implementation 'com.android.support:cardview-v7:26.0.1'
implementation 'com.android.support:design:26.0.1'
implementation 'com.android.support:percent:26.0.1'
implementation 'dev.dworks.libs:volleyplus:+'
implementation 'com.google.guava:guava:21.0'
implementation 'com.facebook.fresco:fresco:1.0.1'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.wdullaer:materialdatetimepicker:3.1.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.stfalcon:frescoimageviewer:0.4.0'
implementation 'com.github.piotrek1543:CustomSpinner:0.1'
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.github.satyan:sugar:1.4'
implementation 'com.hedgehog.ratingbar:app:1.1.2'
implementation project(':sandriosCamera')
implementation('org.apache.httpcomponents:httpmime:4.2.6') {
exclude module: 'httpclient'
}
implementation 'com.googlecode.json-simple:json-simple:1.1'
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}
subprojects {
project.plugins.whenPluginAdded { plugin ->
if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = false
} else if
("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = false
}
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
}
}
apply plugin: 'com.jakewharton.hugo'
also my another module gradle
apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'
buildscript {
repositories {
jcenter()
jcenter()
maven { url "https://maven.google.com" }
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
}
}
group = 'com.sandrios.android'
version = '1.0.8'
ext {
PUBLISH_GROUP_ID = 'com.sandrios.android'
PUBLISH_ARTIFACT_ID = 'sandriosCamera'
PUBLISH_VERSION = '1.0.8'
PUBLISH_CODE = 9
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
versionCode PUBLISH_CODE
versionName PUBLISH_VERSION
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
task generateSourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier 'sources'
}
task generateJavadocs(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath()
.join(File.pathSeparator))
}
task generateJavadocsJar(type: Jar) {
from generateJavadocs.destinationDir
classifier 'javadoc'
}
generateJavadocsJar.dependsOn generateJavadocs
artifacts {
archives generateSourcesJar
archives generateJavadocsJar
}
install {
repositories.mavenInstaller {
pom.project {
name PUBLISH_GROUP_ID
description 'Simple integration of universal camera in android for easy image and video capture.'
url 'https://github.com/sandrios/sandriosCamera'
inceptionYear '2016'
packaging 'aar'
version PUBLISH_VERSION
scm {
connection 'https://github.com/sandrios/sandriosCamera.git'
url 'https://github.com/sandrios/sandriosCamera'
}
developers {
developer {
name 'arpitgandhi9'
}
}
}
}
}
bintray {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
user = properties.getProperty('bintray.user')
key = properties.getProperty('bintray.apikey')
configurations = ['archives']
pkg {
repo = 'android'
name = 'sandriosCamera'
userOrg = 'sandriosstudios'
desc = 'Android solution to simplify work with different camera apis.'
licenses = ['MIT']
labels = ['android', 'camera', 'photo', 'video']
websiteUrl = 'https://github.com/sandrios/sandriosCamera'
issueTrackerUrl = 'https://github.com/sandrios/sandriosCamera/issues'
vcsUrl = 'https://github.com/sandrios/sandriosCamera.git'
version {
name = PUBLISH_VERSION
vcsTag = PUBLISH_VERSION
desc = 'Minor fixes.'
released = new Date()
}
}
}
repositories {
jcenter()
}
dependencies {
implementation 'com.android.support:support-v4:26.0.0'
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support:recyclerview-v7:26.0.0'
implementation 'com.github.bumptech.glide:glide:3.6.1'
implementation 'com.yalantis:ucrop:2.2.0'
implementation 'gun0912.ted:tedpermission:1.0.2'
}
and also project level 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:3.0.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
please help me to get rid of this error
It is important part:
You need to add this in that module's build.gradle where it's not added like app module.
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Also you forgot to add repo for plugin:
buildscript {
repositories {
jcenter()
google()
}
}
I had the same errors(SimException) that you encountered. I had 3 modules in android clean architecture project:
data(android library)
domain(plain java module)
presentation(app - all android stuff)
solution
navigate to File/Project Structure...
make sure your modules has the same Source and Target Compatibility (1.8 in this case)
I added a library with the compileOptions Java 1.8, and In my main project dont.
Fixed adding:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Found my answer, for me personally it was using
implementation "com.google.guava:guava:23.0"
Instead of
implementation "com.google.guava:guava:23.0-android"
I was having the same issue. I had recently deleted my .gradle cache folder, and reinstalled Android Studio and the SDK. Eventually when trying to git bisect the problem, it went away. I can only speculate as to why this happened, but I suspect that downloading older versions of the build tools and SDK, and building (and presumably caching) versions of our code with those older tools caused it to be built in a way that didn't cause issues.
This points to some sort of bug in the way that the newer (API 26?) build tools are building the source code, and so my recommendation if you're seeing this problem and the other solutions don't work, is to lower your target SDK version to 25 or lower, install the necessary build tools, and try compiling your code with those, before reverting to build tools 26 or higher.
Related
I am updating my project's Gradle plugin from 2.1.2 to 3.1.0 but the gradle starts throwing error while build :
Cannot create variant 'android-lint' after configuration
':app:debugRuntimeElements' has been resolved
project level gradle :
// Top-level build file
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'org.ajoberstar:gradle-git:0.6.3'
//noinspection GradleDynamicVersion
classpath 'io.fabric.tools:gradle:1.+'
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
classpath 'com.google.gms:google-services:3.0.0'
}
}
// Used to disable preDex, will speed up clean build but slow down incremental builds.
project.ext.preDexLibs = !project.hasProperty('disablePreDex')
subprojects {
project.plugins.whenPluginAdded { plugin ->
if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
} else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
}
}
}
allprojects {
repositories {
jcenter()
}
}
library level gradle :
apply plugin: 'com.android.library'
setVersion '1.2'
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
configurations {
classpaths
}
def sharedManifest = manifest {
attributes('Specification-Title': 'My App',
'Specification-Version': '2.1',
'Specification-Vendor': 'App Vendor',
'Implementation-Title': 'App',
'Implementation-Version': '2.1',
'Implementation-Vendor': 'App Vendor')
}
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 27
consumerProguardFile file("proguard-project.txt")
}
buildTypes {
debug {
testCoverageEnabled true
}
}
// work-around for duplicate files during packaging of APK
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(':exclude-doclet')
implementation 'com.android.support:support-annotations:27.0.2'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'commons-io:commons-io:2.4'
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
implementation 'com.google.code.gson:gson:2.4'
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.1.7'
classpaths files(new File(System.getenv("ANDROID_HOME") + "/platforms/android-${Integer.parseInt(rootProject.ANDROID_BUILD_SDK_VERSION)}/android.jar"),
new File(System.getenv("ANDROID_HOME") + "/extras/android/support/v4/android-support-v4.jar"))
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'org.mockito:mockito-core:1.10.19'
}
android.libraryVariants.all { variant ->
String name = variant.buildType.name
task("generate${name.capitalize()}Javadoc", type: Javadoc) {
dependsOn variant.javaCompiler
description "Generates Javadoc for $project.name."
title "App $project.version"
source = variant.javaCompiler.source
classpath += project.files(variant.javaCompiler.classpath.files, android.getBootClasspath())
List<File> pathList = new ArrayList<File>()
pathList.add(new File(project(':exclude-doclet').libsDir,
"ExcludeDoclet-${project(':exclude-doclet').version}.jar"))
options {
doclet = "ExcludeDoclet"
docletpath = pathList
encoding = "UTF-8"
classpath = configurations.classpaths.files.asType(List)
linksOffline "http://developer.android.com/reference", "${android.sdkDirectory}/docs/reference"
links "http://docs.oracle.com/javase/7/docs/api/",
"http://square.github.io/retrofit/2.x/retrofit/",
"http://square.github.io/okhttp/2.x/okhttp/",
"http://reactivex.io/RxJava/javadoc/"
memberLevel = JavadocMemberLevel.PUBLIC
header = "AppKit"
}
exclude '**/BuildConfig.java'
exclude '**/R.java'
failOnError true
doLast {
copy {
from 'src/javadoc/assets/'
into destinationDir.path + '/assets/'
}
}
}
task("assemble${name.capitalize()}JavadocJar", type: Jar) {
dependsOn "generate${name.capitalize()}Javadoc"
description "Assembles Jar contaning Javadoc for $project.name."
from project.tasks.getByName("generate${name.capitalize()}Javadoc").destinationDir
classifier = 'javadoc'
manifest {
from sharedManifest
}
}
task("assemble${name.capitalize()}Jar", type: Jar) {
dependsOn variant.javaCompiler
description "Assembles Jar contaning $project.name."
from variant.javaCompiler.destinationDir
manifest {
from sharedManifest
}
}
artifacts {
archives project.tasks.getByName("assemble${name.capitalize()}Jar")
archives project.tasks.getByName("assemble${name.capitalize()}JavadocJar")
}
}
I am stuck with this issue and don't find any solution. Can anyone help me out.
I had the same issue with another library as you have.
I could resolve that with replacing this line:
classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
with:
doFirst { classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar) },
"This is due to new Gradle plugin when AndroidStudio gets updated that goes in conflict with JavaDoc plugin", If you have Javadoc task you must be able to find the same line.
Today I updated to the latest version of crashlytics which was not updated from a very long time.
I am getting the below error while building the file.
Error:No such property: betaDistributionApkFilePath for class:
java.lang.String
I am not setting any betaDistributionApkFilePath property in my gradle file.
This happened after I updated it to the latest version by following the instructions given on the fabric's website. I tried down grading it to a bit older version, but no help. I also, tried to found out more about the error, but it seems that I am the first to face this.
my project level build.gradle
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.google.android.gms', module: 'play-services'
}
buildscript {
ext {
// root project
androidGradleVersion = "3.0.1"
googleServices = "3.2.0"
crashlytics = "1.25.1"
}
repositories {
jcenter()
mavenCentral()
google()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "com.android.tools.build:gradle:$androidGradleVersion"
classpath "com.google.gms:google-services:$googleServices"
classpath "io.fabric.tools:gradle:$crashlytics"
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And this is my App level build.gradle
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
ext {
// android
playService = "11.4.2"
supportLibrary = "27.0.2"
constrainLayout = "1.0.2"
// libraries
retofit = "1.9.0"
okHttp = "2.0.0"
eventBus = "1.3.8"
picasso = "2.5.2"
calligraphy = "2.3.0"
socketIo = "0.3.0"
facebook = "4.30.0"
circularReveal = "1.3.1"
imageCropper = "1.2.2"
expandableRecyclerView = "2.1.1"
crashlytics = "2.9.0"
selectableBackgroudImageView = "1.0.1"
multidex = "1.0.1"
}
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "myappid"
minSdkVersion 16
targetSdkVersion 21
versionCode 01
versionName "01"
multiDexEnabled true
}
buildTypes {
debug {
resValue "string", "app_name", "MyApp Dev"
applicationIdSuffix ".debug"
}
release {
resValue "string", "app_name", "MyApp"
zipAlignEnabled true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "6g"
}
sourceSets {
main {
res.srcDirs = ['src/main/res', 'src/main/res/anim-v21']
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
repositories {
mavenCentral()
maven {
url "https://jitpack.io"
}
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
implementation files('libs/YouTubeAndroidPlayerApi.jar')
implementation "com.google.firebase:firebase-database:$playService"
implementation "com.google.firebase:firebase-auth:$playService"
implementation "com.google.firebase:firebase-core:$playService"
implementation "com.google.firebase:firebase-messaging:$playService"
implementation "com.google.android.gms:play-services-cast:$playService"
implementation "com.google.android.gms:play-services-gcm:$playService"
implementation "com.google.android.gms:play-services-analytics:$playService"
implementation "com.google.android.gms:play-services-maps:$playService"
implementation "com.google.android.gms:play-services-location:$playService"
implementation "com.google.android.gms:play-services-auth:$playService"
implementation "com.squareup.retrofit:retrofit:$retofit"
implementation "com.squareup.okhttp:okhttp-urlconnection:$okHttp"
implementation "com.squareup.okhttp:okhttp:$okHttp"
implementation "com.squareup:otto:$eventBus"
implementation "com.squareup.picasso:picasso:$picasso"
implementation "com.android.support:support-v4:$supportLibrary"
implementation "com.android.support:recyclerview-v7:$supportLibrary"
implementation "com.android.support:design:$supportLibrary"
implementation "com.android.support:appcompat-v7:$supportLibrary"
implementation "com.android.support:cardview-v7:$supportLibrary"
implementation "com.android.support:mediarouter-v7:$supportLibrary"
implementation "com.android.support.constraint:constraint-layout:$constrainLayout"
implementation "uk.co.chrisjenx:calligraphy:$calligraphy"
implementation "com.github.nkzawa:socket.io-client:$socketIo"
implementation "com.facebook.android:facebook-android-sdk:$facebook"
implementation "com.facebook.android:facebook-login:$facebook"
implementation "com.github.ozodrukh:CircularReveal:$circularReveal"
implementation "com.theartofdev.edmodo:android-image-cropper:$imageCropper"
implementation "com.bignerdranch.android:expandablerecyclerview:$expandableRecyclerView"
implementation("com.crashlytics.sdk.android:crashlytics:$crashlytics#aar") {
transitive = true
}
implementation "com.joooonho:selectableroundedimageview:$selectableBackgroudImageView"
implementation "com.android.support:multidex:$multidex"
}
apply plugin: 'com.google.gms.google-services'
Below lines in your app level build.gradle is causing the issue.
ext {
// android
playService = "11.4.2"
supportLibrary = "27.0.2"
constrainLayout = "1.0.2"
// libraries
retofit = "1.9.0"
okHttp = "2.0.0"
eventBus = "1.3.8"
picasso = "2.5.2"
calligraphy = "2.3.0"
socketIo = "0.3.0"
facebook = "4.30.0"
circularReveal = "1.3.1"
imageCropper = "1.2.2"
expandableRecyclerView = "2.1.1"
crashlytics = "2.9.0"
selectableBackgroudImageView = "1.0.1"
multidex = "1.0.1"
}
Declare it inside buildScript{} in project level build.gradle
buildscript {
ext {
crashlytics = '2.9.0'
}
}
And for accessing these variables inside app level build.gradle, use like this
compile("com.crashlytics.sdk.android:crashlytics:$rootProject.ext.crashlytics#aar") {
transitive = true
}
Hope this helps...
The error:
Error:Execution failed for task ':synclib:compileKotlin'.
> com.intellij.openapi.fileTypes.LanguageFileType.<init>(Lcom/intellij/lang/Language;)V
The build.gradle file of the synclib module:
apply plugin: 'java'
apply plugin: 'kotlin'
compileJava {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
// compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.firebase:firebase-client-jvm:2.2.3'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile project(':jamodel')
}
buildscript {
ext.kotlin_version = '1.0.0'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
How to fix or diagnose this?
This is a working configuration. You can adapt it to your multi-project setup:
/build.gradle
buildscript {
ext.kotlin_version = '1.0.4'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
}
ext {
androidBuildToolsVersion = "23.0.3"
androidMinSdkVersion = 16
androidTargetSdkVersion = 23
androidCompileSdkVersion = 23
androidApplicationId = "com.some.example"
androidVersionCode = 1
androidVersionName = "1.0"
supportVersion = "24.0.0"
}
}
/app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion parent.ext.androidCompileSdkVersion
buildToolsVersion parent.ext.androidBuildToolsVersion
defaultConfig {
minSdkVersion parent.ext.androidMinSdkVersion
targetSdkVersion parent.ext.androidTargetSdkVersion
versionCode parent.ext.androidVersionCode
versionName parent.ext.androidVersionName
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
dexOptions {
preDexLibraries = false
jumboMode = false
javaMaxHeapSize "4g"
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
Follow these instructions or check: https://kotlinlang.org/docs/tutorials/kotlin-android.html
Choose Help | Find Action on the main menu or press CTRL+Shift+A.
Search for this item:
You would be prompted for kotlin version.
Choose the latest available from the list of installed versions.
Now build.gradle file for the application should be updated.
The last thing to do is to sync the project. You can press 'Sync Now' in a prompt or invoke an action Sync Project with Gradle Files.
Hope it will help
ensure all your apps and libs build.gradle's ext.kotlin_version equal to your installed Kotlin version
buildscript {
ext.kotlin_version = PROP_KOTLIN_VERSION // 1.1.2-3 // this should equal to your installed Kotlin version
//...
}
I am attempting to follow the Android Studio Experimental Plugin User Guide instructions located at:
http://tools.android.com/tech-docs/new-build-system/gradle-experimental
to modify the Mapbox GL Native library located at:
https://github.com/mapbox/mapbox-gl-native
In specific, I have modified the following Android files:
https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/gradle/wrapper/gradle-wrapper.properties
https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/build.gradle
https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/MapboxGLAndroidSDK/build.gradle
https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
My goal is to modify the library so I can debug it. Ideally I would be able to use Android Studio to build the library and debug the C/C++ code. So far I can build it, but I can't debug it. A programmer working at Mapbox told me they don't how to debug the Android code either, so I suspect this isn't an easy goal to reach.
I have made many different attempts to apply the Android Studio Experimental Plugin User Guide instructions, but I'm not experienced at Gradle and my latest attempt is leaving me with the following error message which I don't understand:
Gradle 'android' project refresh failed
Error:Cause:org.gradle.api.internal.ExtensibleDynamicObject
Does anyone know how to modify these files to have them build a debuggable Android NDK Library? What is causing the above error?
I am using:
> Linux Mint 17.2
> Android Studio 2.1.1
> Build #AI-143.2821654, built on April 28, 2016
> JRE: 1.8.0_65-b17 amd64
> JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation
Below are the 4 files as I currently have them modified. Since I am new to Gradle, do not assume I have made any modfications correctly. I was merely attempting to apply the Android Studio Experimental Plugin User Guide instructions until I got a successful build.
Thanks
#// mapbox-gl-native/platform/android/gradle/wrapper/gradle-wrapper.properties
#Thu Apr 07 14:21:05 CDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#//distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-bin.zip
#//distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-all.zip
distributionSha256Sum=e77064981906cd0476ff1e0de3e6fef747bd18e140960f1915cca8ff6c33ab5c
// mapbox-gl-native/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
dependencies {
// classpath 'com.android.tools.build:gradle:2.1.0'
//classpath 'com.android.tools.build:gradle-experimental:0.7.0'
classpath 'com.android.tools.build:gradle-experimental:0.8.0-alpha2'
classpath 'com.github.JakeWharton:sdk-manager-plugin:220bf7a88a7072df3ed16dc8466fb144f2817070'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
// mapbox-gl-native/platform/android/MapboxGLAndroidSDK/build.gradle
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.model.library'
apply plugin: 'checkstyle'
apply plugin: 'maven'
apply plugin: 'signing'
allprojects {
group project.GROUP
version project.VERSION_NAME
repositories {
mavenCentral()
}
}
repositories {
mavenCentral()
}
ext {
supportLibVersion = '23.4.0'
}
dependencies {
compile "com.android.support:support-annotations:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile 'com.squareup.okhttp3:okhttp:3.3.0'
compile 'com.mapzen.android:lost:1.1.0'
}
model {
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_MIN_SDK)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
sourceSets {
main.res.srcDirs += 'src/main/res-public'
}
repositories {
mavenCentral()
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
checkAllWarnings true
warningsAsErrors true
}
buildTypes {
debug {
jniDebuggable true
buildConfigField "String", "MAPBOX_EVENTS_USER_AGENT_BASE", new StringBuilder().append("\"").append("MapboxEventsAndroid/").append(project.VERSION_NAME).append("\"").toString()
}
release {
jniDebuggable false
buildConfigField "String", "MAPBOX_EVENTS_USER_AGENT_BASE", new StringBuilder().append("\"").append("MapboxEventsAndroid/").append(project.VERSION_NAME).append("\"").toString()
consumerProguardFiles 'proguard-rules.pro'
}
}
}
}
configurations {
all*.exclude group: 'commons-logging', module: 'commons-logging'
all*.exclude group: 'commons-collections', module: 'commons-collections'
}
model {
android.libraryVariants.all { variant ->
def name = variant.name
task "javadoc$name"(type: Javadoc) {
description = "Generates javadoc for build $name"
failOnError = false
destinationDir = new File(destinationDir, variant.baseName)
source = files(variant.javaCompile.source)
classpath = files(variant.javaCompile.classpath.files) + files(android.bootClasspath)
exclude '**/R.java', '**/BuildConfig.java', 'com/almeros/**'
options.windowTitle("Mapbox Android SDK $VERSION_NAME Reference")
options.docTitle("Mapbox Android SDK $VERSION_NAME")
options.header("Mapbox Android SDK $VERSION_NAME Reference")
options.bottom("© 2015–2016 Mapbox. All rights reserved.")
options.links("http://docs.oracle.com/javase/7/docs/api/")
options.linksOffline("http://d.android.com/reference/", "$System.env.ANDROID_HOME/docs/reference")
options.overview("src/main/java/overview.html")
options.group("Mapbox Android SDK", "com.mapbox.*")
options.group("Third Party Libraries", "com.almeros.*")
// TODO exclude generated R, BuildConfig, com.almeros.*
}
}
}
checkstyle {
configFile project.file('../checks.xml')
showViolations true
}
/*
task cleanJNIBuilds {
def jniLibsDir = new File("MapboxGLAndroidSDK/src/main/jniLibs")
delete jniLibsDir.absolutePath
}
*/
model
{
android.libraryVariants.all { variant ->
def name = variant.buildType.name
def checkstyle = project.tasks.create "checkstyle${name.capitalize()}", Checkstyle
checkstyle.dependsOn variant.javaCompile
checkstyle.source variant.javaCompile.source
checkstyle.classpath = project.fileTree(variant.javaCompile.destinationDir)
checkstyle.exclude('**/BuildConfig.java')
checkstyle.exclude('**/R.java')
checkstyle.exclude('**/com/almeros/android/multitouch/**')
project.tasks.getByName("check").dependsOn checkstyle
}
// From https://raw.github.com/mcxiaoke/gradle-mvn-push/master/jar.gradle
android.libraryVariants.all { variant ->
def jarTask = project.tasks.create(name: "jar${variant.name.capitalize()}", type: Jar) {
from variant.javaCompile.destinationDir
exclude "**/R.class"
exclude "**/BuildConfig.class"
}
jarTask.dependsOn variant.javaCompile
artifacts.add('archives', jarTask);
}
}
// From https://raw.github.com/mcxiaoke/gradle-mvn-push/master/gradle-mvn-push.gradle
def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}
def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL :
"https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL :
"https://oss.sonatype.org/content/repositories/snapshots/"
}
def getRepositoryUsername() {
return hasProperty('USERNAME') ? USERNAME :
(hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "")
}
def getRepositoryPassword() {
return hasProperty('PASSWORD') ? PASSWORD :
(hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "")
}
task apklib(type: Zip) {
appendix = extension = 'apklib'
from 'AndroidManifest.xml'
into('res') {
from 'res'
}
into('src') {
from 'src'
}
}
artifacts {
archives apklib
}
afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(),
password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(),
password: getRepositoryPassword())
}
/*
// Leaving out as artifact was incorrectly named when found
addFilter('aar') { artifact, file ->
artifact.name == archivesBaseName
}
addFilter('apklib') { artifact, file ->
artifact.name == archivesBaseName + '-apklib'
}
*/
pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
}
}
signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
model {
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.sourceFiles
classpath = files(android.bootClasspath)
}
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
model {
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
}
task makeClean(type: Exec) {
workingDir '../../'
commandLine 'make', 'clean'
}
task makeAndroid(type: Exec) {
workingDir '../../'
commandLine 'make', 'android'
}
task makeAndroidAll(type: Exec) {
workingDir '../../'
commandLine 'make', 'apackage'
}
// mapbox-gl-native/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.model.application'
apply plugin: 'checkstyle'
task accessToken {
def tokenFile = new File("MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml")
if (!tokenFile.exists()) {
String tokenFileContents = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<resources>\n" +
" <string name=\"mapbox_access_token\">" + "$System.env.MAPBOX_ACCESS_TOKEN" + "</string>\n" +
"</resources>"
if (tokenFileContents == null) {
throw new InvalidUserDataException("You must set the MAPBOX_ACCESS_TOKEN environment variable.")
}
tokenFile.write(tokenFileContents)
}
}
gradle.projectsEvaluated {
// preBuild.dependsOn('accessToken')
}
ext {
supportLibVersion = '23.4.0'
}
model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.mapbox.mapboxsdk.testapp"
minSdkVersion.apiLevel 15
targetSdkVersion.apiLevel 23
versionCode 9
versionName "4.1.0"
// Specify AndroidJUnitRunner as the default test instrumentation runner
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'LICENSE.txt'
}
lintOptions {
checkAllWarnings true
warningsAsErrors true
disable 'IconDensities'
disable 'InvalidPackage'
}
testOptions {
unitTests.returnDefaultValues = true
}
buildTypes {
debug {
// run code coverage reports
testCoverageEnabled = true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
}
dependencies {
compile(project(':MapboxGLAndroidSDK')) {
transitive = true
}
// Support libraries
compile "com.android.support:support-annotations:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
// Leak Canary
//debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
//releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
// Directions SDK
compile('com.mapbox.mapboxsdk:mapbox-android-directions:1.0.0#aar') {
transitive = true
}
// Geocoder SDK
compile('com.mapbox.mapboxsdk:mapbox-android-geocoder:1.0.0#aar') {
transitive = true
}
// Testing dependencies
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile "com.android.support:support-annotations:${supportLibVersion}"
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.5.4'
}
checkstyle {
configFile project.file('../checks.xml')
showViolations true
}
model {
android.applicationVariants.all { variant ->
def name = variant.buildType.name
def checkstyle = project.tasks.create "checkstyle${name.capitalize()}", Checkstyle
checkstyle.dependsOn variant.javaCompile
checkstyle.source variant.javaCompile.source
checkstyle.classpath = project.fileTree(variant.javaCompile.destinationDir)
checkstyle.exclude('**/BuildConfig.java')
checkstyle.exclude('**/R.java')
project.tasks.getByName("check").dependsOn checkstyle
}
}
Your gradle approach is essentially rewriting or porting the Android SDK Makefile to gradle. To solve what you are doing on Linux, you will likely need to modify the existing Makefiles.
The reason is that the Mapbox Android SDK build process uses make android to build the target libmapbox-gl.so. The Gradle project you have includes the .so file in with your usual Java code.
make android makes a call into mapbox-gl-native/Makefile
and also generates mapbox-gl-native/build/android-arm-v7/Makefile, which you may have to research how to modify to generate debug information as Chris Stratton mentions in the comments above.
When you do get around to modifying your C++, you will then need to modify the settings.gradle to make use of your modified .so for Android.
include ':MapboxGLAndroidSDK'
project(':MapboxGLAndroidSDK').projectDir = new File(rootProject.projectDir, '<relative-path-to>/../mapbox-gl-native/platform/android/MapboxGLAndroidSDK')
include ':app'
Another thing to consider — Can you build a debuggable version for Linux?
We have successfully debugged C++ for the Mapbox SDK using the Xcode debugger, as we built an iOS app as well. I know this will not fit your exact needs, but I mention it in case anyone else in your lab or organization has access to Xcode on OS X and can start debugging using make iproj.
I already tried the solution (Using ViewPagerIndicator library with Android Studio and Gradle) but not successful. Still got this error message
Error:A problem occurred configuring project ':app'.
> Artifact 'library.aar (com.viewpagerindicator:library:2.4.1)' not found.
Searched in the following locations:
https://repo1.maven.org/maven2/com/viewpagerindicator/library/2.4.1/library-2.4.1.aar
What I trying to do is install this plugin (https://github.com/JakeWharton/ViewPagerIndicator) via gradle. Below is my build.gradle.
apply plugin: 'com.android.application'
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.xxxxx.xxxxx"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.viewpagerindicator:library:2.4.1#aar'
}
Add:
repositories {
maven {
url "https://jitpack.io"
}
}
before mavenCentral()
And to dependencies
compile('com.github.JakeWharton:ViewPagerIndicator:2.4.1#aar') {
exclude module: 'support-v4'
}
I think you can miss this line classpath 'com.android.tools.build:gradle:1.2.3'
My gradle:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.n1to.testapp"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
// if you have multiple outputs (when using splits), you may want to have other index than 0
// you should set your package name here if you are using different application IDs
// resourcePackageName "your.package.name"
// You can set optional annotation processing options here, like these commented options:
// logLevel 'INFO'
// logFile '/var/log/aa.log'
}
}
buildscript {
repositories {
maven { url "https://jitpack.io" }
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
dependencies {
// replace with the current version of the Android plugin
classpath 'com.android.tools.build:gradle:1.2.3'
// replace with the current version of the android-apt plugin
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
repositories {
maven { url "https://jitpack.io" }
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
mavenLocal()
}
dependencies {
compile 'org.androidannotations:androidannotations:3.3.1'
apt 'org.androidannotations:androidannotations:3.3.1'
compile 'org.projectlombok:lombok:1.16.4'
compile('com.android.support:appcompat-v7:22.2.0') {
exclude module: 'support-v4'
}
compile('com.android.support:recyclerview-v7:22.2.0') {
exclude module: 'support-v4'
}
compile('com.android.support:cardview-v7:22.2.0') {
exclude module: 'support-v4'
}
compile('com.android.support:design:22.2.0') {
exclude module: 'support-v4'
}
compile 'com.android.support:support-v4:22.1.1'
compile('com.github.JakeWharton:ViewPagerIndicator:2.4.1#aar') {
exclude module: 'support-v4'
}
}