Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes when made apk with api key. It's working fine before #254

Closed
ubitechdevelopers opened this issue Apr 28, 2020 · 4 comments
Closed

Comments

@ubitechdevelopers
Copy link

ubitechdevelopers commented Apr 28, 2020

My app was working fine with all features when I made it for debug purpose without an api key and played it on my connected mobile from android studio. But when I purchased the key and made apk it creches on start up with an exception

Your Environment

  • Plugin version: 1.7.0

  • Platform: Android

  • OS version: 7.1.2

  • Device manufacturer / model: Redmi Y1

  • Flutter info (flutter doctor):
    Doctor summary (to see all details, run flutter doctor -v):
    [√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.18362.778], locale en-IN)
    [√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    [√] Android Studio (version 3.6)
    [√] Connected device (1 available)

  • Plugin config:

Manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.ubitech.vtlattendance" android:versionCode="10001" android:versionName="1.0.1"
    xmlns:tools="http://schemas.android.com/tools"
    >

    <!-- The INTERNET permission is required for development. Specifically,
         flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.CAMERA" />


    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name=".Application"
        android:label="@string/shr_app_name"
        android:icon="@mipmap/ic_launcher"
        tools:replace="android:label"
        android:roundIcon="@mipmap/ic_launcher_round">

        <meta-data android:name="com.google.android.geo.API_KEY" android:value="*****"/>
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize"
            android:screenOrientation="portrait">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <meta-data android:name="com.transistorsoft.locationmanager.license" android:value="******" />
        <meta-data android:name="com.transistorsoft.locationmanager.ENCRYPTION_PASSWORD" android:value="transistorsoft" />
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <activity android:name="com.apptreesoftware.barcodescan.BarcodeScannerActivity"/>
    </application>
</manifest>


package org.ubitech.vtlattendance;

import android.os.StrictMode;

import io.flutter.app.FlutterApplication;

public class Application  extends FlutterApplication {
    @Override
    public void onCreate() {
        // Strict mode.  Should be disabled on RELEASE.
        /*
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                .detectDiskReads()
                .detectDiskWrites()
                .detectAll()
                .penaltyLog()
                .build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                .detectLeakedSqlLiteObjects()
                .detectLeakedClosableObjects()
                .penaltyLog()
                .penaltyDeath()
                .build());
        */
        super.onCreate();
    }
}



package org.ubitech.vtlattendance;

import android.os.Build;

import androidx.annotation.NonNull;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {
  @Override
  public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
    GeneratedPluginRegistrant.registerWith(flutterEngine);
  }

  /**
   * This is required to solve Flutter bug booting my old Nexus 4 @4.4.4
   * https://github.com/flutter/flutter/issues/46172#issuecomment-569525397
   */
  @Override
  public void onFlutterUiDisplayed() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      reportFullyDrawn();
    }
  }
}


Expected Behavior

The app should run normally as it is running while debugging

Actual Behavior

App is crashing on start

Steps to Reproduce

Context

I created tha apk with the command flutter build apk

Debug logs

Logs

2020-04-28 16:31:22.357 25515-25515/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.ubitech.vtlattendance, PID: 25515
    java.lang.ExceptionInInitializerError
        at com.transistorsoft.locationmanager.b.E.a()
        at d.k.a.a.G.a(:17)
        at d.k.a.a.H.onAttachedToActivity(:1)
        at io.flutter.embedding.engine.e.a(:8)
        at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(:11)
        at org.ubitech.vtlattendance.MainActivity.a(:1)
        at e.a.b.a.h.a(:13)
        at e.a.b.a.e.onCreate(:5)
        at android.app.Activity.performCreate(Activity.java:6861)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2816)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1555)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:163)
        at android.app.ActivityThread.main(ActivityThread.java:6383)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
        at d.k.b.a.a()
        at com.transistorsoft.locationmanager.b.E.<clinit>()
        at com.transistorsoft.locationmanager.b.E.a() 
        at d.k.a.a.G.a(:17) 
        at d.k.a.a.H.onAttachedToActivity(:1) 
        at io.flutter.embedding.engine.e.a(:8) 
        at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(:11) 
        at org.ubitech.vtlattendance.MainActivity.a(:1) 
        at e.a.b.a.h.a(:13) 
        at e.a.b.a.e.onCreate(:5) 
        at android.app.Activity.performCreate(Activity.java:6861) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2816) 
        at android.app.ActivityThread.-wrap12(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1555) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:163) 
        at android.app.ActivityThread.main(ActivityThread.java:6383) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794) 


@christocracy
Copy link
Member

Please review setup steps and ensure you’ve performed all steps

@ubitechdevelopers
Copy link
Author

I just read your demo app and made mine. Could you point me to the steps with a link please.

@christocracy
Copy link
Member

See the readme in this repo. There’s a clearly defined Table of Contents linking to Setup Instructions.

@ubitechdevelopers
Copy link
Author

I just missed to go to that hyperlink :). Thanks a lot. Its working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants