diff --git a/mastodon/build.gradle b/mastodon/build.gradle index 5a523fa9..8e4d9ba6 100644 --- a/mastodon/build.gradle +++ b/mastodon/build.gradle @@ -10,7 +10,7 @@ android { applicationId "org.joinmastodon.android" minSdk 23 targetSdk 31 - versionCode 2 + versionCode 3 versionName "0.1" } @@ -23,7 +23,8 @@ android { debuggable true } appcenterPrivateBeta{ - initWith debug + initWith release + minifyEnabled false versionNameSuffix "-priv-beta" } appcenterPublicBeta{ diff --git a/mastodon/src/appcenter/java/org/joinmastodon/android/AppCenterWrapper.java b/mastodon/src/appcenter/java/org/joinmastodon/android/AppCenterWrapper.java index f6ef2dd4..e027da17 100644 --- a/mastodon/src/appcenter/java/org/joinmastodon/android/AppCenterWrapper.java +++ b/mastodon/src/appcenter/java/org/joinmastodon/android/AppCenterWrapper.java @@ -12,6 +12,8 @@ public class AppCenterWrapper{ private static final String TAG="AppCenterWrapper"; public static void init(Application app){ + if(AppCenter.isConfigured()) + return; Log.i(TAG, "initializing AppCenter SDK, build type is "+BuildConfig.BUILD_TYPE); if(BuildConfig.BUILD_TYPE.equals("appcenterPrivateBeta")) diff --git a/mastodon/src/main/java/org/joinmastodon/android/MainActivity.java b/mastodon/src/main/java/org/joinmastodon/android/MainActivity.java index e4292315..d736f043 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/MainActivity.java +++ b/mastodon/src/main/java/org/joinmastodon/android/MainActivity.java @@ -1,11 +1,14 @@ package org.joinmastodon.android; +import android.app.Application; import android.os.Bundle; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.fragments.HomeFragment; import org.joinmastodon.android.fragments.SplashFragment; +import java.lang.reflect.InvocationTargetException; + import androidx.annotation.Nullable; import me.grishka.appkit.FragmentStackActivity; @@ -26,5 +29,12 @@ public class MainActivity extends FragmentStackActivity{ showFragmentClearingBackStack(fragment); } } + + if(BuildConfig.BUILD_TYPE.startsWith("appcenter")){ + // Call the appcenter SDK wrapper through reflection because it is only present in beta builds + try{ + Class.forName("org.joinmastodon.android.AppCenterWrapper").getMethod("init", Application.class).invoke(null, getApplication()); + }catch(ClassNotFoundException|NoSuchMethodException|IllegalAccessException|InvocationTargetException ignore){} + } } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/MastodonApp.java b/mastodon/src/main/java/org/joinmastodon/android/MastodonApp.java index f281a69b..52c13902 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/MastodonApp.java +++ b/mastodon/src/main/java/org/joinmastodon/android/MastodonApp.java @@ -23,10 +23,5 @@ public class MastodonApp extends Application{ ImageCache.setParams(params); NetworkUtils.setUserAgent("MastodonAndroid/"+BuildConfig.VERSION_NAME); context=getApplicationContext(); - - // Call the appcenter SDK wrapper through reflection because it is only present in beta builds - try{ - Class.forName("org.joinmastodon.android.AppCenterWrapper").getMethod("init", Application.class).invoke(null, this); - }catch(ClassNotFoundException|NoSuchMethodException|IllegalAccessException|InvocationTargetException ignore){} } }