Updated my android studio to 0.5.1 just now and facing so many issues:
This is my build.gradle file:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
}
}
apply plugin: 'android'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
signingConfigs {
release {
storeFile file('dsc.jks')
storePassword 'dscneo'
keyAlias 'dsc'
keyPassword 'dscneo'
}
}
buildTypes {
debug {
versionNameSuffix '-DEBUG'
}
beta {
versionNameSuffix '-BETA'
}
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile files('libs/gson-2.2.4.jar')
compile files('libs/gson-2.2.4-sources.jar')
compile files('libs/volley.jar')
compile files('libs/gson-2.2.4-javadoc.jar')
compile project(':HorizontalVariableListView')
compile files('libs/sugar-1.2.jar')
compile 'com.crashlytics.android:crashlytics:1.+'
compile project(':shopify_view_pager')
compile project(':shopify_smoothProgressBar_library')
compile files('libs/butterknife-4.0.1.jar')
compile project(':shopify_sliding_pane_library')
}
This is the error that is prompted:
Gradle 'shopping-app-android' project refresh failed:
Build script error, unsupported Gradle DSL method found: 'release()'!
Possible causes could be:
- you are using Gradle version where the method is absent
- you didn't apply Gradle plugin which provides the method
- or there is a mistake in a build script
Please help!
I have just started using Android Studio.
It seems like you're still running gradle plugin 0.8. See Migrating From 0.8 to 0.9
Related
When I try to compile my project I get this weird error:
What went wrong:
Execution failed for task ':android:transformClassesWithDexBuilderForProdDevelopmentDebug'.
com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/.../.gradle/caches/transforms-1/files-1.1/play-services-location-11.2.2.aar/f5b9886774f73d8b64cfd9701f91e8cc/jars/classes.jar
What I tried:
Added multiDexEnabled true to app gradle.
Added android.enableD8.desugaring = true and android.enableD8=true to gradle.properties
Also removed .gradle folder and did rebuild + clean
Also did the following: SDK manager -> Google play services -> updated. Rebuild + clean afterwards.
AS version: 3.1.4
App gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion Android.compileSdkVersion
buildToolsVersion Android.buildToolsVersion
flavorDimensions "...", "type"
defaultConfig {
applicationId "xxx"
versionName 'xxx'
versionCode xxx
minSdkVersion 21
targetSdkVersion Android.targetSdkVersion //Android.targetSdkVersion holds value "27"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "6g"
preDexLibraries = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
test {
dimension "xxx"
applicationIdSuffix '.xxx'
versionNameSuffix 'x'
manifestPlaceholders = [onesignal_app_id : "",
onesignal_google_project_number: ""]
}
production {
dimension "xxx"
manifestPlaceholders = [onesignal_app_id : "",
onesignal_google_project_number: ""]
}
development {
dimension "type"
resConfigs "xxhdpi"
}
normal {
dimension "type"
}
}
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "..."
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
exclude 'build-data.properties'
exclude 'error_prone/Annotations.gwt.xml'
exclude 'third_party/java_src/error_prone/project/annotations/Annotations.gwt.xml'
exclude 'third_party/java_src/error_prone/project/annotations/Google_internal.gwt.xml'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
androidExtensions {
experimental = true
}
}
dependencies {
implementation project(':projectxxx')
implementation project(':tifCompanion')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/YouTubeAndroidPlayerApi.jar')
kapt "android.arch.lifecycle:compiler:1.1.1"
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation "com.android.support.constraint:constraint-layout:1.1.0-beta5"
kapt "com.google.dagger:dagger-compiler:2.16"
api "com.android.support:leanback-v17:27.1.1"
implementation "com.android.support:leanback-v17:27.1.1"
api "com.android.support:recommendation:27.1.1"
implementation "com.android.support:recyclerview-v7:27.1.1"
implementation "com.android.support:support-vector-drawable:27.1.1"
}
projectxxx which was implemented has these dependencies:
dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
api project(':JsonAPI') //https://github.com/faogustavo/JSONApi
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.61"
implementation "com.onesignal:OneSignal:3.6.5"
api "com.google.android.gms:play-services-base:15.0.1"
api "com.google.android.gms:play-services-analytics:15.0.0"
api "com.android.support:support-annotations:27.1.1"
}
You are using all play-services with versions 15.x.x, and error is mentioning 11.2.2, this means that some other library is bringing in this dependency.
This type of error can be solved by following steps:
run ./gradlew :app:dependencies command in terminal. (This will generate dependency hierarchy)
Check for the dependency bringing in play-services-location dependency and exclude it from that dependency like below:
compile ('<dependency-bringing-play-services-location>') {
exclude group:'com.google.android.gms'
}
Add play-services location dependency explicitly.
I'm quite a new Android developer. I' working on a project with a few other guys and we use GitHub to collaborate. The particular app that gives me an error doesn't run on any of the other guys phones, so I've been given the task to fix it. Here is the problem: when i run the app on my phone, it crashes... Here is the error:
java.lang.NoClassDefFoundError:
Failed resolution of: Lcom/crashlytics/android/Crashlytics;
and the second error on the logcat is:
java.lang.ClassNotFoundException:
Didn't find class "com.crashlytics.android.Crashlytics"
on path: DexPathList[[dex fil
e...
I tried searching online but the suggestion to enable Multidex in the gradle folder didn't seem to help.
Thanx
This is my gradle file...
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/gen_approx_cyrillic.txt'
}
defaultConfig {
applicationId "com.aftarobot.assocbuilder"
minSdkVersion 19
targetSdkVersion 24
versionCode 7
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:2.0.1'
resolutionStrategy.force 'org.hamcrest:hamcrest-core:1.3'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
// compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true;
}
// compile project(path: ':aftarobotbackend', configuration: 'android-endpoints')
// compile project(path: ':xbackend', configuration: 'android-endpoints')
compile project(':aftarobotlibrary')
compile 'com.google.code.findbugs:jsr305:2.0.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
testCompile 'junit:junit:4.10'
}
apply plugin: 'com.google.gms.google-services'
Hi guys thanx for contributing. I got it fixed. I ended up going to the master branch of GitHub and copying that version of the manifest and it worked. I didn't have to change anything in the gradle file
I'm trying to import a Jgrapht library in my app, but every time i try to build APK, android studio shows me:
Error:Execution failed for task ':app:transformClassesWithPreJackPackagedLibrariesForDebug'.
com.android.sched.scheduler.RunnerProcessException: Error during 'TypeLegalizer' runner on 'private final synthetic int org.jgrapht.alg.vertexcover.-$Lambda$25.$m$0(java.lang.Object arg0)': Unexpected error during visit: com.android.jack.ir.ast.JReturnStatement at "Unknown source info"
What is the problem and how i can fix it? Please help me!
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
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
}
defaultConfig {
applicationId "it.univpm.gruppoids.iotforemergencyandnavigation"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
}
compileOptions {
incremental true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
repositories {
maven {
url "https://mint.splunk.com/gradle/"
}
}
packagingOptions {
exclude 'META-INF/services/org.apache.sis.storage.DataStoreProvider'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/MANIFEST.MF'
}
/*buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}*/
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:percent:25.0.0'
compile 'com.android.support:support-v4:25.0.0'
compile 'com.journeyapps:zxing-android-embedded:3.2.0#aar'
compile 'com.google.zxing:core:3.2.1'
compile files('lib/jgrapht-ext-1.0.0-uber.jar')
compile files('lib/jgrapht-ext-1.0.0.jar')
compile files('lib/jgrapht-demo-1.0.0.jar')
compile files('lib/jgraph-5.13.0.0.jar')
compile files('lib/antlr4-runtime-4.5.3.jar')
compile files('lib/jgrapht-core-1.0.0.jar')
}
And the other gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
/*maven {
url "https://plugins.gradle.org/m2/"
}*/
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'me.tatarka:gradle-retrolambda:3.3.0'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
apply plugin: 'me.tatarka.retrolambda'
task clean(type: Delete) {
delete rootProject.buildDir
}
The easiest way I can think of is to use maven, then simply add the dependencies to your project. That'll save you a lot of hassel in setting up JGraphT by yourself.
you can find how to use maven with android studio here: How to import Maven dependency in Android Studio/IntelliJ?
While JGraphT's dependencies are here under the "Maven Releases" section:
http://jgrapht.org/
I am trying to incorporate Houndify API into my project. However my gradle file would not build.
I downloaded a sample project from their site and it worked normally. I am migrating codes from that project gradle file to mine.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "edu.drexel.cs.ptn32.pennapps"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
signingConfigs {
debug {
storeFile file("debug.keystore")
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
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 {
maven {
// The username and password for this repo is set below
url 'https://houndify.com/maven/'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile ('hound.android:hound-sdk:0.2.15#aar'){
transitive=true
}
compile ('hound.android:phrasespotter:1.4.0'){
transitive=true
}
}
setHoundifyMavenCredentials("user", "pw")
def setHoundifyMavenCredentials(username, password) {
for (repo in repositories) {
if (repo.properties.url.toString().equals("https://houndify.com/maven/")) {
repo.properties.credentials.username = username
repo.properties.credentials.password = password
}
}
}
Sorry to hear you are having problems migrating the Houndify SDK into your app. To make things easier, we've just removed the password restriction on the https://houndify.com/maven/ website. This means you can remove the setHoundifyMavenCredentials() portion from your build.gradle file. I suggest pulling the latest version of the Houndify sample app houndify-sdk-sample-0.2.17.zip and making sure it builds OK on your system, then all you should need to do is to add these lines to your build.gradle and it should pull in the Houndify libraries.
repositories {
maven {
url 'https://houndify.com/maven/'
}
}
dependencies {
compile ('hound.android:hound-sdk:0.2.15#aar'){
transitive=true
}
compile ('hound.android:phrasespotter:1.4.0'){
transitive=true
}
}
Finally make sure you Android build system is up-to-date.
Please let us know if you are still running into problems and thanks for your feedback. http://www.soundhound.com/contact
I am always getting java.lang.ClassNotFoundException: ru.ooolpi.lpiapp.ui.activity.MainActivity. But I have such class. Later I discovered that my project files are missing from apk.
My build script:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
// classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.10.1'
//classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
}
}
//apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
repositories {
maven { url 'https://github.com/donnfelker/mvn-repo/raw/master/' }
maven { url 'https://repo.commonsware.com.s3.amazonaws.com' }
jcenter()
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup:otto:1.3.8'
apt 'com.squareup.dagger:dagger-compiler:1.0.1'
}
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
//applicationId "ru.ooolpi.lpiapp"
minSdkVersion 10
targetSdkVersion 22
versionCode 2
versionName "1.0.1"
multiDexEnabled true
}
packagingOptions {
// Exclude file to avoid
// Error: Duplicate files during packaging of APK
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/notice.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE.txt'
exclude '.readme'
}
dexOptions {
jumboMode = true
javaMaxHeapSize "4g"
}
signingConfigs {
release {
storeFile file('../devcert.jks')
storePassword '123456'
keyAlias 'dev'
keyPassword '123456'
}
}
lintOptions {
//disable 'InvalidPackage'
abortOnError false
}
compileOptions{
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
zipAlignEnabled true // this is default for release
}
debug {
applicationIdSuffix '.debug'
minifyEnabled false
}
}
}
I tried to build with Android Studio and just with gradlew. Result is the same - my files are not included into apk.
Update:
My project structure
Have a look at your proguard config file.
Make sure you don't strip off any class that you use in your apk. To manually keep the classes, add these lines:
-keep class ru.ooolpi.lpiapp.** { *; }
-dontwarn ru.ooolpi.lpiapp.**
The issue was that I used different versions for dagger and it's compiler.
How it was:
compile 'com.squareup.dagger:dagger:1.2.2'
apt 'com.squareup.dagger:dagger-compiler:1.0.1'
It should look like:
compile 'com.squareup.dagger:dagger:1.2.2'
apt 'com.squareup.dagger:dagger-compiler:1.2.2'
So, Android Studio refused to highlight issues in my code (I don't know why these things are related).