Application does not work after generating . APK

Asked

Viewed 2,441 times

6

I am facing a problem when trying to generate an app apk developed in Android Studio. After generating the . apk to install the app on other phones, the app is installed but does not open.

On mobile phones with android 9 it presents error "Application presents faults continuously" and on other versions of android it presents error "Application stopped working".

The mode I use to generate apk is: Build menu -> Generate Signed Bundle/APK... and I follow the steps of generating key, registering etc. I have managed other applications in the same way and I have not had any problems. To debug the application I use both a physical device (Android 8.0) as emulators (varied Android versions) and at least this way the application does not show errors, neither in the part Debug screen nor in Logcat. I’m gonna post here my Manifest and Gradle.

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.example.wqueiroz.publictaxi">

    <uses-permission android:name="android.permission.INTERNET" />

    <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:ignore="GoogleAppIndexingWarning">
        <activity
            android:name=".UI.MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar"></activity>
        <activity android:name=".UI.UI.ScanActivity" />

        <activity android:name=".UI.UI.InformacoesViagemActivity" />
        <activity android:name=".UI.UI.PerfilActivity" />
        <activity android:name=".UI.UI.CreditosActivity" />
        <activity android:name=".UI.UI.LoginActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".UI.UI.CadastroActivity"></activity>
    </application>
</manifest>

Gradle:

apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.example.wqueiroz.publictaxi"
    minSdkVersion 17
    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'
    }
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
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'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
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.google.zxing:core:3.2.1'
implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'

implementation 'de.hdodenhof:circleimageview:3.0.1'}

Note: I already looked for some answer here on the site for this problem: Application does not work on a particular device after compiled and Problems to generate APK in Android Studio, but they didn’t solve my situation.

If anyone can give a hint of how I can resolve this situation I thank you already.

  • Have you tried migrating the project to Androidx? If I’m not mistaken you have the documentation from Google itself that was instructing all developers to migrate their projects to the most current version of the SDK if I’m not mistaken to targetSDK 28, can also try to migrate it to Androidx, maybe solve your problem

  • @Q. Wesley, I have seen problems of this kind and if they were missing libs, maybe you are using features that are not available for the versions you are testing, or there is a loss of libs during packaging.

  • Assuming the application is working in debug mode (with the phone plugged into the computer and running in Android Studio), you have to look at the logcat microscopically. There are several errors that are forgiven during debug mode but not when generating an APK. If you have nothing suspicious, then you need to look at the logcat of the APK execution.

1 answer

3


Either you get an error-enabled device to turn on developer mode and use logcat for information, or you can post the app to the play store as an internal test version and register the email of people who are having problems with the app to download directly through the link you will send. It takes a little work to do this but this way the developer panel will point out the error and in which versions of android it occurs.

Another thing Voce can do is go into each of the activities and look for those yellow markings that are warnings. These messages point to possible causes of errors like nullpointerexception but don’t stop the build.Sometimes the warnings pointed out by these markers don’t cause errors at first but then start to stop the app. This ignoring these warnings has already happened to me so I leave the suggestion.

  • Good morning @Uliano Santos, I thank you for your answer, but I’m already doing just that. In case I test this application with a Moto Z2 with Android 9.0 with active developer mode. When starting the application logcat does not present me any error, it goes up normally. What I find strange is that on other devices (Samsung A70 Android 9.0 for example) when installing the apk it runs the first time, all activitys without problem, however, when the application is closed and reopened it presents the errors described in the topic.

  • I will answer. I left two more suggestions.

  • I really appreciate your tips, after publishing a trial version on google play and testing on the devices that were in trouble, I ended up discovering the problem of my application through the feedback of the tests performed before the launch, now I can continue my development, thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.