HMS-Core / hms-mapkit-demo

HMS Map Kit demo provides an example of intergrating HMS Map Android SDK. Personalizing how your map displays and interacts with your users tailors their experience to them
https://developer.huawei.com/consumer/en/hms/huawei-MapKit?ha_source=hms1
Apache License 2.0
115 stars 43 forks source link

App crashes #2

Closed usmani93 closed 4 years ago

usmani93 commented 4 years ago

hey, I just downloaded the code, ran it on my huawei HMS phone, got first screen ok, but when I am clicking on any of the buttons it is crashing don't know what is causing this, but the logcat says :

2020-06-17 13:57:02.167 20131-20131/com.huawei.hms.maps.sample E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.huawei.hms.maps.sample, PID: 20131
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.huawei.hms.maps.sample/com.huawei.hms.maps.sample.CircleDemoActivity}: android.view.InflateException: Binary XML file line #7 in com.huawei.hms.maps.sample:layout/activity_circle_demo: Binary XML file line #7 in com.huawei.hms.maps.sample:layout/activity_circle_demo: Error inflating class fragment
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3895)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4074)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:219)
        at android.app.ActivityThread.main(ActivityThread.java:8347)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
     Caused by: android.view.InflateException: Binary XML file line #7 in com.huawei.hms.maps.sample:layout/activity_circle_demo: Binary XML file line #7 in com.huawei.hms.maps.sample:layout/activity_circle_demo: Error inflating class fragment
     Caused by: android.view.InflateException: Binary XML file line #7 in com.huawei.hms.maps.sample:layout/activity_circle_demo: Error inflating class fragment
     Caused by: com.huawei.hms.maps.model.RuntimeRemoteException: AppId is null. Please check if agconnect-services.json file is is added in app project.
        at com.huawei.hms.maps.common.util.AppInfoUtil.a(AppInfoUtil.java:22)
        at com.huawei.hms.maps.SupportMapFragment$SupportMapFragmentDeferredLifecycleHelper.b(SupportMapFragment.java:293)
        at com.huawei.hms.maps.SupportMapFragment$SupportMapFragmentDeferredLifecycleHelper.createDelegate(SupportMapFragment.java:275)
        at com.huawei.hms.feature.dynamic.DeferredLifecycleHelper.a(Unknown Source:44)
        at com.huawei.hms.feature.dynamic.DeferredLifecycleHelper.onInflate(Unknown Source:5)
        at com.huawei.hms.maps.SupportMapFragment.onInflate(SupportMapFragment.java:103)
        at androidx.fragment.app.Fragment.onInflate(Fragment.java:1384)
        at androidx.fragment.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3744)
        at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:120)
        at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:405)
        at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:387)
        at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1079)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1007)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:971)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1133)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1094)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:536)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.huawei.hms.maps.sample.CircleDemoActivity.onCreate(CircleDemoActivity.java:74)
        at android.app.Activity.performCreate(Activity.java:8085)
        at android.app.Activity.performCreate(Activity.java:8073)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3868)
2020-06-17 13:57:02.167 20131-20131/com.huawei.hms.maps.sample E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4074)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:219)
        at android.app.ActivityThread.main(ActivityThread.java:8347)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
2020-06-17 13:57:02.184 20131-20131/com.huawei.hms.maps.sample I/Process: Sending signal. PID: 20131 SIG: 9

any help would be appreciated.

usmani93 commented 4 years ago

do i have to include the config file from Huawei developer console?

shifangjing-1029 commented 4 years ago

AppId is null. Please check if agconnect-services.json file is added in app project. You may add a agconnect-services.json file and a signing certificate to your project. For details, visit: https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/hms-map-configuringinagc

usmani93 commented 4 years ago

thankyou so much for this, i added the SH256 key on the dev console and re added the agconnect services into the android project, maps showing everything fine,

Zhuinden commented 3 years ago

The trick really was to just add agconnect to /app/ (and set up and enable map services)