I am working on an app and trying to use the new material design, aka sdk version 21.
I had everything working fine, and then wanted to at a fab (floating action button) using this library.
I added this library as a submodule, using
git submodule add https://github.com/shamanland/floating-action-button
while under C:\Users\USER\AndroidStudioProjects\ProjectName
My file structure looks like so
ProjectName
app
floating-action-button
The issue
Before everything was totally fine, I was able to build and run the project.
But, ever since adding this submodule, when trying to run it, I get the error
Failure [INSTALL_FAILED_OLDER_SDK]
So I'm thinking it has to do with the submodule, but I'm not sure how.
app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.0.2'
defaultConfig {
applicationId "com.mayuonline.ribbit"
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.+'
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:palette-v7:+'
}
app/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="resume.kelseyhrubes">
<uses-sdk tools:node="replace" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
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>
f-a-b/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
classpath 'org.robolectric:robolectric-gradle-plugin:0.11.0'
}
}
def isSnapshot() {
return VERSION_NAME.contains('SNAPSHOT')
}
def gradleMvnPush = new File(buildDir, 'gradle-mvn-push.gradle')
if (!gradleMvnPush.exists()) {
buildDir.mkdirs()
ant.get(src: GRADLE_MVN_PUSH, dest: gradleMvnPush)
}
setProperty('GRADLE_MVN_PUSH', gradleMvnPush)
subprojects {
group GROUP
version VERSION_NAME
apply plugin: 'android-sdk-manager'
if (name.startsWith('lib')) {
apply plugin: 'com.android.library'
} else {
apply plugin: 'com.android.application'
}
android {
compileSdkVersion COMPILE_SDK_VERSION as int
buildToolsVersion BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion TARGET_SDK_VERSION as int
versionCode 1
versionName '1.0'
// workaround for https://code.google.com/p/android/issues/detail?id=52962
buildConfigField 'boolean', 'SNAPSHOT', isSnapshot().toString()
}
lintOptions {
abortOnError false
}
}
repositories {
mavenLocal()
mavenCentral()
}
if (isSnapshot()) {
apply plugin: 'robolectric'
dependencies {
// NOTE workaround for sdkmanager plugin
compile 'com.android.support:support-v4:19.0.1'
androidTestCompile 'junit:junit:4.10'
androidTestCompile 'org.robolectric:robolectric:2.3'
androidTestCompile 'com.squareup:fest-android:1.0.8'
}
}
}
f-a-b/AndroidManifest.xml (probably a clue here, I (tried to) bold the areas that Android Studio has turned red
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=" **http://schemas.android.com/apk/res/android** "
package="com.shamanland.fab.example">
<application
android:name=" **.ExampleApplication** "
android:label="#string/app_name"
**android:icon** ="#drawable/ic_launcher"
**android:theme** ="#style/AppTheme"
**android:allowBackup** ="true"
>
<activity android:name=".ExampleListActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=" **.ExampleDetailsActivity** "/>
</application>
</manifest>
I have a strong suspicion that the submodule was added incorrectly.
Really all I want is to use a fab in my app, if anyone can help me figure out what may be wrong, with adding the submodule, or something with my build.gradle, that would really be appreciated!!
This error is usually caused by deploying an APK built with "compileSdkVersion n" to a device or emulator with an API level less than "n". Is your emulator at the right API level?
Related
I'm getting the error unresolved class in my AndroidManifest.xml (and my xml classes under tools:context="...">
However there were 0 errors in my gradle rebuild so I'm not sure where the problem is.
There are no red lines in my app gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.krousorati.truthordare"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
...
def nav_version = "1.0.0-alpha11"
implementation "android.arch.navigation:navigation-fragment:$nav_version" // use -ktx for Kotlin
implementation "android.arch.navigation:navigation-ui:$nav_version" // use -ktx for Kotlin
}
Any idea what the problem is?
And my Project gradle:
buildscript {
ext.kotlin_version = '1.3.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
And here is my Android manifest file:
<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=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts"/>
</application>
android:name=".MainActivity" is a relative class name; expecting MainActivity.kt at the root directory of the package; most likely it is located in a sub-directory and therefore cannot be found. either try fixing the relative class name - or simply use a fully qualified class name. unless knowing how the directory structre looks alike it's difficult to tell, but it might be something along the lines of .activity.MainActivity or com.krousorati.truthordare.activity.MainActivity.
just see what the package statement in MainActivity.kt says.
Instant app working FINE while run the app from android studio but, getting errors while generate the APK build and try to run it from device
getting below error in xiaomi noughat device
instant app crash by giving this message "There was a problem parsing the package"
I have used instant app development version 1.3.0 and also enabled instant app setting from settings > google > instant apps
E/Icon: Unable to load resource 0x00000000 from pkg=com.android.systemui
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:201)
at android.content.res.MiuiResourcesImpl.getValue(MiuiResourcesImpl.java:91)
at android.content.res.Resources.getDrawable(Resources.java:784)
at android.graphics.drawable.Icon.loadDrawableInner(Icon.java:316)
at android.graphics.drawable.Icon.loadDrawable(Icon.java:272)
at android.graphics.drawable.Icon.loadDrawableAsUser(Icon.java:380)
at com.android.systemui.statusbar.ExpandedIcon.getDrawable(ExpandedIcon.java:59)
at com.android.systemui.statusbar.StatusBarIconView.getIcon(StatusBarIconView.java:174)
at com.android.systemui.statusbar.StatusBarIconView.setIcon(StatusBarIconView.java:133)
at com.android.systemui.statusbar.StatusBarIconView.updateDarkMode(StatusBarIconView.java:266)
at com.android.systemui.statusbar.phone.SimpleStatusBar.updateDarkMode(SimpleStatusBar.java:264)
at com.android.systemui.statusbar.phone.PhoneStatusBar$17.run(PhoneStatusBar.java:3494)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6195)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764)
and getting below error in lollipop device
package - Android: Parse error when parsing manifest. Discontinuing installation
Here i listed out manifest files and gradle files of my project
instantapp gradle
apply plugin: 'com.android.instantapp'
dependencies {
implementation project(':feature')
implementation project(':base')}
feature module gradle and manifest
apply plugin: 'com.android.feature'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':base')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstinstantapp.feature">
<uses-permission android:name="android.permission.INTERNET" />
<application>
<activity android:name="com.example.myfirstinstantapp.feature.MainActivity">
<meta-data
android:name="default-url"
android:value="https://myfirstinstantapp.example.com/hello" />
<intent-filter android:order="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="myfirstinstantapp.example.com"
android:pathPattern="/.*"
android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
===========================================
base module gradle and manifest
apply plugin: 'com.android.feature'
android {
compileSdkVersion 28
baseFeature true
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api 'com.android.support:appcompat-v7:28.0.0-alpha3'
api 'com.android.support.constraint:constraint-layout:1.1.2'
application project(':app')
feature project(':feature')
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstinstantapp">
<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=".MainActivity" />
</application>
</manifest>
===========================================
app gradle and manifest
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myfirstinstantapp.app"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(':feature')
implementation project(':base')
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstinstantapp.app" />
===========================================
project level gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here i attached screenshot of my project structure
I have an error with my app in Android studio:
Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I use Gradle and Kotlin.
Android Studio 3.0.1.
Windows 10 Pro 64.
I have research this theme on SO and I have tried some solution from here, like that:
Clean and rebuild project. No changes.
Change 'compile' in gradle to 'implementation'. No changes.
Delete .gradle and build directories. No changes.
Add multiDexEnabled true in defaultConfig in gradle. In this case, I have another error:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [G:\work\myapp\app\build\intermediates\multi-dex\debug\componentClasses.jar]
(Can't read [C:\Users\Public\.gradle\caches\transforms-1\files-1.1\support-core-utils-27.0.2.aar\e1c9881d763269b67bf59dc03d19c305\jars\classes.jar(;;;;;;**.class)]
(Duplicate zip entry [classes.jar:android/support/v4/content/PermissionChecker$PermissionResult.class]))
My build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
multiDexEnabled true
applicationId "myapp"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
applicationIdSuffix ".dev"
}
staging {
debuggable true
applicationIdSuffix ".sta"
}
preproduction {
applicationIdSuffix ".pre"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.basecamp:turbolinks:1.0.7'
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'
// The Client SDK resides on jCenter
implementation 'com.twilio:client-android:1.2.21'
}
My AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tunnll.passenger">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<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=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.twilio.client.TwilioClientService"
android:exported="false" android:stopWithTask="true"/>
</application>
What am I missing?
UPD
It seems I found out the point after that the problem has appeared. It was after adding Twilio configuration. I used this manual: Twilio and Android
This is all changes that have been done:
Add to build.gradle:
implementation 'com.twilio:client-android:1.2.21'
Add to AndroidManifest:
<service android:name="com.twilio.client.TwilioClientService"
android:exported="false" android:stopWithTask="true"/>
Add to proguard-rules.pro
# Twilio Client
-keep class com.twilio.** { *; }
# Apache HttpClient
-dontwarn org.apache.http.**
That's all. Before this changes I didn't have this error
Use this in your build.gradle in app Module if you want to read an .aar file
for your libs dir:
repositories{
flatDir{
dirs 'libs'
}
}
dependencies {
compile(name:'nameOfYourAARFileWithoutExtension', ext:'aar')
}
But it seems that your problem is multidex(means that you have more than 65K methods in your project so use this:
android {
defaultConfig {
multiDexEnabled true
}
}
and if your minSdk < 20 then use this as well:
compile 'com.android.support:multidex:1.0.1'
Hope it helps!!!
After I imported the BaseGameUtils module (for Google Play Game Services), I got this error. The error log says to use in my Module Manifest File:
<uses-sdk tools:overrideLibrary="android.support.v7.appcompat"/>
Then, when I build this happens:
Then, the errorLog suggests me to import this into my Module's Manifest File:
<uses-sdk tools:overrideLibrary="android.support.v4"/>
Then, I get the first error again, It's a never-ending back and forth cycle.
App Manifest XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tool="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
package="reflexflash.gespanet2015.com.flashreflex">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Arcade1">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
App Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
defaultConfig {
applicationId "reflexflash.gespanet2015.com.flashreflex"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':BaseGameUtils')
}
Module Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.google.example.games.basegameutils"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk tools:overrideLibrary="android.support.v4"/>
<application>
</application>
</manifest>
Module Gradle:
apply plugin: 'com.android.library'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
dependencies {
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!project.hasProperty('appcompat_library_version')) {
ext.appcompat_library_version = '20.0.+'
}
if (!project.hasProperty('support_library_version')) {
ext.support_library_version = '20.0.+'
}
if (!project.hasProperty('gms_library_version')) {
ext.gms_library_version = '8.1.0'
}
compile "com.android.support:appcompat-v7:${appcompat_library_version}"
compile "com.android.support:support-v4:${support_library_version}"
compile "com.google.android.gms:play-services- games:${gms_library_version}"
compile "com.google.android.gms:play-services- plus:${gms_library_version}"
}
android {
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!project.hasProperty('android_compile_version')) {
ext.android_compile_version = 23
}
if (!project.hasProperty('android_version')) {
ext.android_version = '23'
}
compileSdkVersion android_compile_version
buildToolsVersion android_version
Change your gradle (app).
android {
...
defaultConfig {
applicationId "your.package.name"
minSdkVersion 7 //here your problem. Change that 1 to 7(or value of the that you are currently using libraries)
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
multiDexEnabled true
...
}
In the Module's manifest, i added this line to fix it:
<uses-sdk android:minSdkVersion="15" />
my minSdkVersion is also stated in my app's gradle file.
So,I am importing a project that works perfectly (tested on 4 phones) from Eclipse to Android studio and when I run the application WITHOUT modifying anything at all, it won't allow me to use the internet at all.
As for code...it's pointless to post any ,because I created an application that does nothing but connect to a database and it still won't work, while the exact same code will work perfectly when I run the application from Eclipse to my phone. (Same phone by the way)
Just to make sure that won't be an answer: I HAVE the permissions added in my manifest.
Any suggestions?
//manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="vlad.tests.com.udptextconnection" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<activity
android:name=".MainActivity"
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>
// Build.gradle (module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "vlad.tests.com.udptextconnection"
minSdkVersion 15
targetSdkVersion 21
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.1.1'
}
//Build.gradle (project [project-name])
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Try putting permissions outside of application tag.
Not sure if it'd work but, try and clean your project.
Go to Build->Clean Project.
Try Build->Rebuild Project.