This is the first time I've used Android Studio and I can't build this app.
Can anyone tell me how to fix this code?
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "org.settingsdeployer"
minSdkVersion 15
targetSdkVersion 21
versionCode 4
versionName "1.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
normal {
applicationId "org.settingsdeployer"
versionCode 4
versionName "1.2"
}
french {
applicationId "org.settingsdeployer"
versionCode 5
versionName "1.2_fr"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
I'm getting these errors when it tries to sync:
ERROR: All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
Affected Modules: org.settingsdeployer
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: org.settingsdeployer
I made the requested changes and it sync'd but now I can't make an apk:
That's great, it sync'd the build without errors but now when I try to generate an apk i get more errors. I have no idea what I'm doing!
UPDATE:
After adding flavorDimensions it sync'd the build without errors but now when I try to generate an apk i get more errors. I have no idea what I'm doing!. Here is the error log:
Executing tasks: [:org.settingsdeployer:assembleNormalRelease]
Task :org.settingsdeployer:preBuild UP-TO-DATE Task :org.settingsdeployer:preNormalReleaseBuild UP-TO-DATE Task :org.settingsdeployer:compileNormalReleaseAidl NO-SOURCE Task :org.settingsdeployer:compileNormalReleaseRenderscript UP-TO-DATE Task :org.settingsdeployer:checkNormalReleaseManifest UP-TO-DATE Task :org.settingsdeployer:generateNormalReleaseBuildConfig UP-TO-DATE Task :org.settingsdeployer:prepareLintJar UP-TO-DATE Task :org.settingsdeployer:generateNormalReleaseSources UP-TO-DATE Task :org.settingsdeployer:javaPreCompileNormalRelease UP-TO-DATE Task :org.settingsdeployer:mainApkListPersistenceNormalRelease Task :org.settingsdeployer:generateNormalReleaseResValues UP-TO-DATE Task :org.settingsdeployer:generateNormalReleaseResources UP-TO-DATE Task :org.settingsdeployer:mergeNormalReleaseResources FAILED
FAILURE: Build failed with an exception.
What went wrong: Could not resolve all files for configuration ':org.settingsdeployer:_internal_aapt2_binary'.
Could not find com.android.tools.build:aapt2:3.3.1-5013011. Searched in the following locations:
file:/C:/Users/Stuart/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
file:/C:/Users/Stuart/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
file:/C:/Users/Stuart/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
file:/C:/Users/Stuart/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
file:/C:/Users/Stuart/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
file:/C:/Users/Stuart/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar Required by: project :org.settingsdeployer
Try: Run with --info or --debug option to get more log output. Run with --scan to get full insights.
I'm getting these errors when it tries to sync: ERROR: All flavors
must now belong to a named flavor dimension. Learn more at
https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
Affected Modules: org.settingsdeployer
The flavor dimension problem is happened because you haven't add the flavorDimensions to your build.gradle. There must be at least one flavorDimensions. Something like this:
android {
...
defaultConfig {...}
buildTypes {
debug{...}
release{...}
}
// you need to specifies one flavor dimension.
flavorDimensions "version"
productFlavors {
normal {
// This property is optional if you are using only one dimension.
dimension "version"
applicationId "org.settingsdeployer"
versionCode 4
versionName "1.2"
}
french {
dimension "version"
applicationId "org.settingsdeployer"
versionCode 5
versionName "1.2_fr"
}
}
}
more details at Configure build variants
WARNING: Configuration 'compile' is obsolete and has been replaced
with 'implementation' and 'api'. It will be removed at the end of
2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: org.settingsdeployer
This warning is telling that we need to use either api or implementation to replace the compilation when adding dependencies. So, change the dependencies block to something like this;
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:21.0.3'
}
Related
I am pretty sure that I have checked all the possible duplicate questions and none solve my problem. I have instant run turned off, I have minfy and shrink set to false. I have cleaned. The keyfile exists and worked perfectly on a previous release of this app. I have tried running the compile with --info but it does not give me any hints as the the problem. The error is:
Execution failed for task ':app:packageRelease'.
Failed to read key myreleasekey from store "C:\Users\Mel\AndroidStudioProjects\tourbuilderkeystore.jks": Cannot recover key
My build gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.myguidedtours.www.tourguide"
minSdkVersion 16
targetSdkVersion 27
versionCode 10
versionName '1.10'
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
// implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-fragment:27.1.1'
implementation 'com.android.support:support-compat:27.1.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.android.gms:play-services-tasks:15.0.1'
implementation 'com.google.android.gms:play-services-basement:15.0.1'
implementation 'com.android.support:mediarouter-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation "com.android.support:exifinterface:27.1.1"
implementation files('libs/PdfViewer.jar')
}
I have been sweating over this for two days - I hope you can help.
Just in case there's someone out there as stupid as me. The prompt for Generate a Signed APK in Android Studio, does not tell you if the passwords you supply are good or bad. I must have miss-keyed one of them, then, because I ticked the remember passwords option, it failed every time I tried to run it. There is no hint that the password may be wrong - usually when you enter a bad password you get immediate feedback.
I am having trouble with dependencies for Elasticsearch High Level Java Client 6.2.2 in Android Studio 3.0.
I have alot of duplicate files in my META-INF directory and sub-directories. I've tried using packagingOptions, doesn't work. Other things that doesn't work
Using default compiler instead of D8
Use older version of Gradle.
Turned off instant run.
Advanced profiling is not on.
Invalidate/manually delete cache.
my app/libs is empty.
I can't exclude group: 'org.apache.httpcomponents', module: 'httpclient' because I'm using the client.
The only thing that will get the app to run is change implementation 'org.elastic... to compileOnly. But this means I cant call the functions at run time.
I am new to android and this is driving me nuts. Should I start poking around in libraries folder .idea\libraries and changing some of these paths? Could this be where the problem is?
Here is the Gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com. .myapplication"
minSdkVersion 26
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
buildToolsVersion '26.0.2'
productFlavors {
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
implementation 'org.elasticsearch.client:elasticsearch-rest-high-level-
client:6.2.2'
annotationProcessor 'org.apache.logging.log4j:log4j-core:2.9.1'
}
This is the error I'm currently getting. With bad formating
Error:com.android.builder.dexing.DexArchiveBuilderException:
Failed to process C:\Users\mmmmmm\.gradle\caches\modules-2\files-
2.1\org.elasticsearch\elasticsearch\6.2.2\16b3f7a7a31b89144723eb85c0583234842f68
4\elasticsearch-6.2.2.jar
Error:com.android.builder.dexing.DexArchiveBuilderException:
java.lang.RuntimeException: java.lang.IllegalArgumentException
Error:java.lang.RuntimeException: java.lang.IllegalArgumentException
Error:java.lang.IllegalArgumentException
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException:
com.android.builder.dexing.DexArchiveBuilderException:
com.android.builder.dexing.DexArchiveBuilderException: Failed to process
C:\Users\mmmmm\.gradle\caches\modules-2\files-
2.1\org.elasticsearch\elasticsearch\6.2.2\16b3f7a7a31b89144723eb85c0583234842f684\elasticsearch-6.2.2.jar
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.1'
defaultConfig {
applicationId "com.example.calendarquickstart"
minSdkVersion 11
targetSdkVersion 24
versionCode 1
multiDexEnabled true
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'pub.devrel:easypermissions:0.1.5'
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-calendar:v3-rev210-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
}
I am trying to use google API for calendar but I am getting following error while running the app"
Information:Gradle tasks [:app:clean, :app:generateDebugSources,
:app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies,
:app:generateDebugAndroidTestSources, :app:assembleDebug]
Error:Execution failed for task
':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: No dex files
created at
C:\Users\user\AndroidStudioProjects\CalendarQuickstart\app\build\intermediates\transforms\dex\debug\folders\1000\10\guava-jdk5-17.0_bbc68f1b67df2c58337cd00757b7bfd105bb5573"
I am following the steps from this link
What changes need to be done in gradle file for running this app?
Try enabling the multidex support in your build.gradle file as stated in Configuring Your App for Multidex with Gradle:
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Additional reading:
Android application (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536—including Android framework methods, library methods, and methods in your own code. In the context of computer science, the term Kilo, K, denotes 1024 (or 2^10). Because 65,536 is equal to 64 X 1024, this limit is referred to as the '64K reference limit'.
Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multidex configuration.
I get an error in running the emulator.
Take a look at my Screenshot.
How can I fix it?
You need to select the device in the list at the top.
It says UNAUTHORIZED which means you should go on the phone and allow debugging from this PC (you should be prompted when you plug in the USB).
If that doesn't work try checking if USB-debugging is enabled and as a last resort allow debugging from any PC (not recommended) in the development settings
As you can see you have to set the emulators minSDK to 19 to run your app...
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.stackoverflow.answer"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
androidTestCompile 'junit:junit:4.12'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Screen Capture
I got the answer.I change the min sdk from 21 to 19 at 'app/build.gradle file'
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
I created new Android Project and tried to run tests (JUnit) and had follow result:
15:28:53: Executing external tasks 'cleanTest test --tests com.binomv.rimidalv.tt.*'...
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'TT'.
Could not resolve all dependencies for configuration ':classpath'.
Artifact 'kxml2.jar (net.sf.kxml:kxml2:2.3.0)' not found.
Searched in the following locations:
https://jcenter.bintray.com/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.jar
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.512 secs
Artifact 'kxml2.jar (net.sf.kxml:kxml2:2.3.0)' not found.
Searched in the following locations:
https://jcenter.bintray.com/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.jar
But if i use test through device - it is ok.
Thank you.
-----UPDATE-----
build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.binomv.rimidalv.tt"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v4:22.0.0'
}
----- SOLUTION -----
You should remove "~/.gradle" folder. Android Studio recreate it.