Application crashing when another activity is added - android

I am creating an android application that logs in the user via email authentication through firebase and on successful login the app will shift to another activity.
Now the problem is while the single activity for login is working fine but as soon as I add another activity on which it has to jump and try to run again then this error
NoClassDefFoundError: Failed resolution of:
Landroid/view/View$OnUnhandledKeyEventListener;
comes up and the application automatically closes.
I have tried many different options but none of them works. Have restarted my pc, invalidated the cache but still no luck.
.gradle file
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.arviadmin"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-compat:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
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'
}
apply plugin: 'com.google.gms.google-services'
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.arviadmin">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<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"></activity>
<activity
android:name=".LoginActivity"
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>

The manifest file seems fine. If everything in LoginActivity, MainActivity and xml are correct I suggest you to delete the build folders - because you have already invalidate the cache.
project-folder/build
project-folder/app/build
If it still don't work I suggest you to comment everything on those classes and start uncommenting while testing.

Related

AAPT Error: attribute 'package' in <manifest> tag is not a valid Android package name

I have looked at the previous answers for this question but the AAPT error still occurs.
error: attribute 'package' in <manifest> tag is not a valid Android package name: 'org.emarti202.gcu.mpd-cw-em'.
Despite my applicationId in the build.gradle and the package names in the AndroidManifest.xml match, they still do not work. Is there a solution for this? Apologies is this is a simple fix, I cant seem to wrap my head around it.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.emarti202.gcu.mpd-cw-em">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="MPD-CW-EM"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="#string/map_key" />
<activity android:name="org.emarti202.gcu.mpd-cw-em.MainActivity2"></activity>
<activity android:name="org.emarti202.gcu.mpd-cw-em.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "org.emarti202.gcu.mpd-cw-em"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.gms:play-services:+'
implementation 'com.android.support:recyclerview-v7:28.0.0'
// implementation 'com.alespero:expandable-cardview:0.6'
// implementation 'com.google.android.gms:play-services-maps:16.1.0'
}
Unfortunately the hyphen '-' is not acceptable in a package name.
Please reference this docs.
https://developer.android.com/guide/topics/manifest/manifest-element.html#package
A full Java-language-style package name for the Android app. The name may contain uppercase or lowercase letters ('A' through 'Z'), numbers, and underscores ('_'). However, individual package name parts may only start with letters.
While building your app into the an application package (APK), the build system uses the package attribute for two things
Please change your package name to 'org.emarti202.gcu.mpd_cw_em'.

Google Play: Can't install app, error 504 (INSTALL_PARSE_FAILED_MANIFEST_MALFORMED)

I have an app that was uploaded to Google Play. The problem is: it does not want to install on some devices, for example a Samsung J7. The other thing is that, I have two same devices (Gionee S Plus), one has Android 7.0 rooted, on which the app is working fine, and the other one is on Android 6.0, but the app does not want to install. When I try to install the app on the second device directly with the apk, I get:
Parse error
There was a problem parsing the package
And when I try to install it from the Store, I get:
Can't install the app
With no other clear message.
After searching for this problem, I found that I needed to do somethings:
Clear Google Play & services data and cache: did not work
Restart phone: did not work
Uninstall Google Play updates: when trying to install with the old version, I get the same error message but this time I got the error message 504. When I searched for this error, I read that I should completely delete all my google accounts, which I did but still the same problem.
I doubted it was the manifest problem, and I decompiled the apk but it looks fine.
Manifest.xml on Android Studio:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<application
android:name="com.myapp.MainApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="#style/PurpeTheme">
<meta-data
android:name="com.onesignal.NotificationOpened.DEFAULT"
android:value="DISABLE" />
<activity android:name="com.myapp.ActivitySplash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.myapp.ActivityHome" />
<activity android:name="com.myapp.ActivityTrack"/>
<activity android:name="com.myapp.ActivityEqualizer" />
<activity android:name="com.myapp.ActivityAboutUs" />
<activity android:name="com.myapp.ActivitySettings" />
<service android:name="com.myapp.services.ServicePlayer" />
<service android:name="com.myapp.services.DownloadService" />
<activity android:name="com.myapp.ActivityFavorites" />
<activity android:name="com.myapp.ActivityPrivacyPolicy" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="#string/admob_app_id" />
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="${crashlyticsEnabled}" />
</application>
</manifest>
build.gradle app level
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'io.objectbox'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.myapp"
minSdkVersion 16
targetSdkVersion 28
versionCode 3
versionName "1.2"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.config
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
manifestPlaceholders = [crashlyticsEnabled: true]
}
debug {
manifestPlaceholders = [crashlyticsEnabled: false]
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'
implementation 'com.google.android.material:material:1.1.0-alpha04'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.gms:play-services-ads:17.2.0'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'jp.wasabeef:blurry:2.1.1'
implementation 'com.sothree.slidinguppanel:library:3.3.0'
implementation 'com.nabinbhandari.android:permissions:3.5'
implementation 'com.orhanobut:dialogplus:1.11#aar'
implementation 'com.diogobernardino:williamchart:2.5.0'
implementation 'com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:0.7.2'
implementation 'com.sdsmdg.harjot:croller:1.0.7'
implementation 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32#aar'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation 'com.wang.avi:library:2.1.3'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'jp.wasabeef:glide-transformations:3.3.0'
implementation 'com.codemybrainsout.rating:ratingdialog:1.0.8'
implementation 'com.github.varunest:sparkbutton:1.0.5'
implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
implementation 'com.google.android.gms:play-services-analytics:16.0.8'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
}
apply plugin: 'com.google.gms.google-services'
Update:
I get INSTALL_PARSE_FAILED_MANIFEST_MALFORMED when trying to install the app from Android Studio to some devices. I found the solution, and it detailed in my answer below.
Actually, the problem was in the package name, apparently some devices and some android versions (Android 6.0) does not accept a capital lettre as the beginning of a package name. And by package name I mean your project file structure, not the application id.
Here is what I did get when I tried the app with the emulator, and what did help me find the problem:

Default activity not found, even though it is declared in Manifest

I have not found the solution to this online. All of my activities are declared, however often Android Studio will tell me it does not find them. It doesn't always occur, and it seems to happen quite randomly. I've cleaned, invalidated and restarted, rebuild, sometimes this will get fixed then start happening again after some time. I'm working in a team on the project, and I seem to be the only one with the bug:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="fall2018.csc2017.GameCentre"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SlidingTiles.SlidingGameActivity" />
<activity android:name=".Score.MenuScoreboardsActivity" />
<activity android:name=".Score.UserScoreboardActivity" />
<activity android:name=".Score.ScoreScreenActivity" />
<activity android:name=".Score.GameScoreboardActivity" />
<activity android:name=".GameLauncherActivity" />
<activity android:name=".RegisterActivity" />
<activity android:name=".SlidingTiles.SlidingTilesStartingActivity" />
<activity android:name=".Simon.SimonGameActivity" />
<activity android:name=".Simon.SimonStartingActivity" />
<activity android:name=".ChooseDimensionActivity"></activity>
</application>
This is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "fall2018.csc2017.GameCentre"
minSdkVersion 27
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
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'
}
It is hard to tell what is the exact issue based on the only information you provided. But, few things you can try to find the issue:
Try running your app on a different physical device or emulator. If
it fixes it, that means that was a device issue.
Set breakpoints on all of your onCreate methods activities, as well as the previous code snippet where the activity will be launching the following activity, for example:
Intent intent = new Intent(context, className);
intent.setFlags(intFlag);
context.startActivity(intent);
And try to debug to see if the activity is being created or being launched. This could be a good start to narrow down the problem. Good luck!
FYI, switch this line :
<activity android:name=".ChooseDimensionActivity"></activity>
to this:
<activity android:name=".ChooseDimensionActivity"/>

I have an gradle error everytime I run the app

I am working with an android project and every time I run the app there is an error of this type :
Manifest merger failed : Attribute application#appComponentFactory
value=(android.support.v4.app.CoreComponentFactory) from
[com.android.support:support-compat:28.0.0]
AndroidManifest.xml:22:18-91 is also present at
[androidx.core:core:1.0.0-alpha1] AndroidManifest.xml:22:18-86
value=(androidx.core.app.CoreComponentFactory). Suggestion: add
'tools:replace="android:appComponentFactory"' to element
at AndroidManifest.xml:10:5-44:19 to override.
And even if I try to do it the way it told me there is another error.
This is the build.gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.community.jboss.visitingcard"
minSdkVersion 19
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'
}
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
//the intro library
implementation 'com.github.msayan:tutorial-view:v1.0.6'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation "com.android.support:preference-v7:28.0.0"
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
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'
}
And this is the Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.community.jboss.visitingcard">
<!--
TODO: Add location/GPS access permissions
TODO: Change the Label of the Activities according to the Activity's
context
TODO: Change App Icon .i.e., ic_launcher
-->
<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=".LoginActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" />
<activity android:name=".VisitingCard.VisitingCardActivity" />
<activity android:name=".IntroScreens.SliderActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- TODO: Add Google Maps API key here -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name=".Maps.MapsActivity"
android:label="#string/title_activity_maps"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" />
<activity android:name=".VisitingCard.ViewVisitingCard" />
<activity
android:name=".SettingsActivity"
android:label="#string/title_activity_settings" />
<activity android:name=".IntroActivity"></activity>
</application>
</manifest>
Add the following line in your manifest :
tools:replace="android:appComponentFactory"
Like this :
<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"
tools:replace="android:appComponentFactory>
//Your code here
</application>
You are using two appcompat dependencies one from support namespace and another one is from androidx namespace.Ideally solution would be move your project completely to androidx and remove the below mentioned dependency,
implementation 'com.android.support:appcompat-v7:28.0.0'
and you could use stable version of andoid x appcompat library
androidx.appcompat:appcompat:1.0.0 instead of androidx.appcompat:appcompat:1.0.0-alpha1'
It seems you decided to use androidX in your project, but using appCompat with androidX together is incorrect.
It's better if you use androidX's libraries, remove appCompat ones.
If you insistent to use androidX remove implementation 'com.android.support:appcompat-v7:28.0.0' in build.gradle file or remove androidX one, otherwise.
for more information about your error :
You can open the "Manifest" file and go to merged tab. At the bottom of file you can see what are wrong.

Having compatibility issues on Google Play with some devices

I've recently just launched my app, and it's going really well! I am having issues with some users, though. Users on older devices such as the Nexus 5X, Huawei P10 Lite, and Meizu M2 Note are saying they are unable to download the app on Google Play because it says it is incompatible with their device. I've already checked the Developer Console and it says the app should support these devices (except the Meizu that one doesn't even show up in the catalog). I've also already run emulators mimicking the devices and everything works fine. All of them are running Android 8.0 which I know for sure is supported by my app.
I've been looking all over google for a way to solve this, but honestly I have no idea what to do anymore. This is my first real app and I can't help but get the feeling that I'm missing some crucial step for widespread release.
Here's my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.balanstudios.einar.workouttimer">
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.vibrate" android:required="false"></uses-feature>
<application
android:name=".BaseApp"
android:allowBackup="true"
android:icon="#mipmap/ic_work_icon_small"
android:label="Robota"
android:roundIcon="#mipmap/ic_work_icon_small_round"
android:supportsRtl="true"
android:theme="#style/WorkoutTimerLight">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="#style/WorkoutTimerLight"
android:windowSoftInputMode="adjustPan">
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
<activity android:name=".SplashScreen"
android:screenOrientation="portrait"
android:theme="#style/WorkoutTimerLight"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"></category>
</intent-filter>
</activity>
</application>
</manifest>
Here's my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.balanstudios.einar.workouttimer"
minSdkVersion 23
targetSdkVersion 28
versionCode 7
versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
lintOptions {
abortOnError false
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support:support-media-compat:28.0.0-alpha3'
implementation 'com.android.support:design:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-v4:28.0.0-alpha3'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.anjlab.android.iab.v3:library:1.0.44'
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'
}
Does anyone have any ideas? I would really appreciate any help!
Play Store Link
Your app has min Sdk = 23 (this gradle line)
minSdkVersion 23
The complaints are probably from users on older versions of Android.

Categories

Resources