I have created a basic Android project following this guide.
Now when I run gradle(version 2.10) in my command line I get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/opt/android-sdk/build-tools/23.0.2/aapt'' finished with non-zero exit value 1
This is my build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
}
And here is my AndroidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.hello"
android:versionCode="1"
android:versionName="1.0.0" >
<application android:label="#string/app_name" >
<activity
android:name=".HelloActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Funny thing is, when I start Android Studio(1.5) and build a test application there it works fine, but doing it in command-line fails. I tried copying the gradle file from AS, to no avail. I checked the installation path, aapt is where it is supposed to be.
I'm quite lost here since I used that very same guide from above a few months ago. Today I updated my Android SDK installation(EDIT: I made sure the right revisions are installed) but I can't get anything to build properly.
Let me know if you need more information, I'm stuck.
I figured it out myself. After reinstalling Gradle, I finally got a new error message that told me in plain english what was wrong(it was a problem with my resources).
This is really weird, since I use Archlinux and all other Gradle updates worked fine before.
Thanks anyway to whomever has given this some thought :)
Related
I tried to install my application in an Android version 12. I added the android:exported for each activity, receiver and filters. This error occurs
Installation did not succeed.
The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
List of apks:
[0] 'C:\Users\Code\MyApp\app\build\outputs\apk\debug\app-debug.apk'
Installation failed due to: 'Failed to commit install session 366841949 with command package install-commit 366841949. Error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl366841949.tmp/base.apk (at Binary XML file line #392): androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present'
Retry
Failed to launch an application on all devices
The merged manifist displays these errors
Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. myapp.app main manifest (this file), line 26
Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. muapp.app main manifest (this file), line 33
Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. myapp.app main manifest (this file), line 40
This is the test AndroidManifest.XML file that causes the errors
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="androidx.test.core" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.REORDER_TASKS" />
<application>
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
android:theme="#android:style/Theme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
android:theme="#android:style/Theme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
android:theme="#android:style/Theme.Dialog" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>
These are the test dependencies I'm using
debugImplementation 'androidx.fragment:fragment-testing:1.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0')
androidTestImplementation('androidx.test:runner:1.4.0')
androidTestImplementation('androidx.test:rules:1.4.0')
The problem occurs in the test package and its auto generated. How to fix it?
I tried multiple solutions to fix the problem but nothing seems to fix it.
These are some solutions I looked into but didn't work for me.
Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]
An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier
The error was fixed by changing this dependency version androidx.fragment:fragment-testing
from version 1.3.5
debugImplementation 'androidx.fragment:fragment-testing:1.3.5'
to version 1.4.0
debugImplementation 'androidx.fragment:fragment-testing:1.4.0'
This answer helped me fix the error https://stackoverflow.com/a/71605255/9770844
Recently I had problems with AAPT2. The problems were caused by my username that contained non-ascii characters. I created another Windows account(without non-ascii characters) and installed Android Studio on it. Then I opened my older project and when AS asked me to update I agreed to that. Now when I try to build my app I get these errors:
Android resource linking failed
D:\Android_Studio\Praca\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
D:\Android_Studio\Praca\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
D:\Android_Studio\Praca\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2970: error: resource android:attr/fontVariationSettings not found.
D:\Android_Studio\Praca\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2971: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Most of threads I found of StackOverflow suggest that this problem might be related to support library, they say that version of it might be wrong. How could I change the version? My project also uses OpenCV library and configuration of it might be invalid.
What I tried already was cleaning and rebuilding project and adjusting compileSDKVersion in Gradle.
Here is values-v28.xml file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Base.Theme.AppCompat" parent="Base.V28.Theme.AppCompat"/>
<style name="Base.Theme.AppCompat.Light" parent="Base.V28.Theme.AppCompat.Light"/>
<style name="Base.V28.Theme.AppCompat" parent="Base.V26.Theme.AppCompat">
<!-- We can use the platform styles on API 28+ -->
<item name="dialogCornerRadius">?android:attr/dialogCornerRadius</item>
</style>
<style name="Base.V28.Theme.AppCompat.Light" parent="Base.V26.Theme.AppCompat.Light">
<!-- We can use the platform styles on API 28+ -->
<item name="dialogCornerRadius">?android:attr/dialogCornerRadius</item>
</style>
And here is Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.kawa.praca">
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Powitanie">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Trening" />
<activity android:name=".Zdjecia" />
<provider
android:name=".DbProvider"
android:authorities="com.example.kawa.praca"
android:exported="true" />
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.android.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/file_paths" />
</provider>
<activity android:name=".AddActivity" />
<activity android:name=".UserPanel" />
<activity android:name=".ScoringPanel" />
<activity android:name=".Scoring" />
<activity android:name=".NewPlanActivity" />
<receiver
android:name=".PlanReceiver"
android:enabled="true"
android:exported="true" />
<activity android:name=".ChartsActivity"></activity>
</application>
</manifest>
Also below is my build.gradle file app module. In this file in sub-clause 'dependencies' entries with support library are underlined and AS shows me a warning:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:customtabs:26.1.0
I tried changing versions to newer or older but this warning still appears.
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.kawa.praca"
minSdkVersion 24
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { jni.srcDirs = ['src/main/jni', 'src/main/jniLibs/'] }
}
// Encapsulates your external native build configurations.
externalNativeBuild {
// Encapsulates your CMake build configurations.
cmake {
// Provides a relative path to your CMake build script.
path "../CMakeLists.txt"
}
}
//buildToolsVersion '27.0.3'
buildToolsVersion '28.0.3'
productFlavors {
}
}
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
//implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:customtabs:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
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 project(':openCVLibrary340')
//implementation 'com.jjoe64:graphview:4.2.2'
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:+'
}
I had the same error fixed it by updating the compilesdkversion to 28, since currently my build tools version is 28.0.3 , hence the version should be same as to have a perfect build.
Also check for your implementation 'com.android.support:appcompat-v7:28.0.0'
Change the respective Dependency versions to 28, it will prevent run time crashing
I am developing a Android Studio project using gradle 2.2 and Google Play Services 12.0.1. I am now trying to add functionality from Google Play Services.
The thing is I am unable to import the Google Play Service library. When I try the following line.
import com.google.android.gms.games.Games;
Or anything similar i get "Cannot resolve symbol Games", Android Studio proposes "Add library <...> to classpath" but that does not seem to change anything.
What I have done so far
I started out following this setup guide. Which simply says to update your build.gradle. My top-level build.gradle contains this,
project(":android") {
apply plugin: "android"
apply plugin: 'com.android.application'
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
< ... >
compile "com.google.android.gms:play-services-games:12.0.1"
}
}
I have also ensured that the buildscript section contains the maven link. I have also checked that Google Play Services are installed from the "SDK Tools" pane in the SDK manager. In addition to this I have added the correct version of Play Services as a dependency in Project structure -> Modules -> Dependencies. Someone suggested on earlier Stack Overflow questions that adding
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
to the AndroidManifest might help, so my Manifest looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="wizard_team.wizards_tale" >
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="27" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/GdxTheme" >
<activity
android:name="wizard_team.wizards_tale.AndroidLauncher"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
I do not receive any error messages when I resync and I have tried to update and restart Android Studio several times. I have also tried "Invalidate chaches/restart..".
During my quest on Google I have found several people experiencing the same problem and I have tried their solutions but nothing has worked. I have spent way to long with this problem, does anyone have any suggestions?
Solved it. As I do not have much experience creating apps I tried importing google play services into the core-module part of my app. For anyone else just getting started, the android specific code such as this should go in android -> java -> [package-name].
Might seem trivial, but as a beginner using this setup tool this problem kept me searching for hours.
So essentially I've been making a game using libgdx and just recently I started to try and add Google Play Game Services and So I tried my hand at it and it seems as though I have completely messed up my .xml file I've tried looking at questions such as How do I resolve this Java Class not found exception? and NoClassDefFoundError - Eclipse and Android, but to no avail.
Here is the runtime error I am recieving.
02-19 19:25:17.772: E/AndroidRuntime(25746): FATAL EXCEPTION: main
02-19 19:25:17.772: E/AndroidRuntime(25746): Process: com.coppercow.minerman, PID: 25746
02-19 19:25:17.772: E/AndroidRuntime(25746): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.coppercow.minerman/com.coppercow.minerman.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.coppercow.minerman.MainActivity" on path: DexPathList[[zip file "/data/app/com.coppercow.minerman-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.coppercow.minerman-2, /vendor/lib, /system/lib]]
The class Name is MainActivity.Java and it is in the src file. I understand that this is done because of one of two things: My .class file, or the .xml file. So here is also my .xml file just in case what I have done wrong is there and not in fact in any .class file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.coppercow.minerman"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
However I've messed around with this xml file quite a lot and so I do not believe it is in here and that My whole problem has to be in some .class file somewhere, but I don't even understand how to access those from eclipse from going off of other questions asked here on StackOverflow.
Try this:
Go to Project/Properties/Java Build Path/Order and Export -- Make sure there's a check in front of Android Dependencies and the support library, if you use it.Mark all checkboxes and Click on Apply and clean the project.
Hope this helps.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android">
<application android:icon="#drawable/ic_launcher" android:label="#string/app_name">
<activity android:name=".hba1c" android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I'm trying to learn Java and need some help with AndroidManifest.xml
My little hello world project is working code-wise, but I'm confused with making changes to the manifest. Specifically, in the code above package name is "com.android" and in data/app my app shows up as com.android-1.apk. When I try to change it to something like com.jocala or com.jocala.hba1c I get package R does not exist errors through my compile, which fails.
What changes do I need to make? Anything else here that is glaringly bad?
I am working using Ant, VI and the Linux console, no Eclipse.
You should change the package of the java code, let it in accordance with the package which you defined in the manifest file.
The manifest holds meta-data corresponding to your android application. Hence, if you needs changes in the package name, make the changes in the java files, change the package name there, there is no sense making a change here. The only changes that are majorly done in the manifest are activity related(for beginners). Have a read here.