androidiosfluttervisual-studio-app-center

AppCenter with Flutter (IOS and Android)


Right now we are developing 2 flutter projects, both is running work on Android and IOS. No problems there (yey) The problem I'm having is, I cannot find a way to implement AppCenter into my project. The guide on the official website is actually very straight-forward but it does not working, gives null-safety error: Cannot run with sound null safety, because the following dependencies don't support null safety: package:appcenter package:appcenter_analytics package:appcenter_crashes

I walked around with --no-sound-null-safety arg but that did not helped with IOS. Cant even "run" the project. My Question About It

Secondly I tried this plugin but no matter how I proceed, I could not manage to make it work both for IOS and Android. Last error I was having was "Unsupported Android Plugin version: 7.0.0." (the instruction was telling me to follow the settings in the example project of the plugin in GitHub) so, I'm at a dead end here..

Can anyone suggest a proper way for me to follow for AppCenter?

Why AppCenter you may ask? Because firebase is only for "test" distribution and I really need to use AppCenter's public publish service.


Solution

  • after spending some hours in pain, I found the solution. So, here's how:

    android\app\src\main\java\com\arkitek\flutter\arkitek_app_internal\MainActivity.java

        package com.arkitek.flutter.arkitek_app_internal;
        import io.flutter.embedding.android.FlutterActivity;
        import com.microsoft.appcenter.AppCenter;
        import com.microsoft.appcenter.analytics.Analytics;
        import com.microsoft.appcenter.crashes.Crashes;
        import com.microsoft.appcenter.distribute.Distribute;
        import android.os.Bundle;
        
        
        public class MainActivity extends FlutterActivity {
        
        @Override
        
        protected void onCreate(Bundle savedInstanceState) {
        
        AppCenter.start(getApplication(), "OUR SECRET KEY", Distribute.class);
        
        AppCenter.setEnabled(true);
        
        super.onCreate(savedInstanceState); 
    }}
    

    And in AndroidManifest.xml file:

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

    app/build.grade:

    dependencies {
    
        def appCenterSdkVersion = '4.2.0'
    
        implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
    
        implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
    
        implementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}"
    
    }
    

    Also,

    To let AppCenter know that, you are releasing an update, you should update your versionCode's in 3 files:

    android\app\build.gradle

    ..
    Android {
    
    defaultConfig {
    applicationId "com.arkitek.flutter.arkitek_app_internal"
    minSdkVersion 21
    targetSdkVersion 30
    versionCode 9
    versionName "1.0.19"
    }
    

    pubspec.yaml ->

    version: 1.0.19+1 
    

    and android\app\src\main\AndroidManifest.xml

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="9"
    android:versionName="1.0.19"
    package="com.arkitek.flutter.arkitek_app_internal">
    

    And that was it. This is how I solved my issues.