I moved the initialization to different pages. On any page, the app wants to initialize it crashes.
I updated the flutter, any packages in my project, and Backendless to 7.2.3. And also tried any solution on the internet I could find.
I even made a balnc project with flutter just put backendless package and initialize it, then build apk and it crashes. Removed the initialization works.
Hello, @Ehsan_Nikaeen1.
Try to call initApp first, and only after that setUrl.
Best Regards, Nikita.
One moment. I will check
@Ehsan_Nikaeen1, I don’t have any problems.
You need to call setUrl
if your app is on EU server. It just needs to be done after initApp
.
Debug version is work as expected for you?
What version of backnedless_sdk are you using?
Yes, I was working fine all way and when I published it to google play I realized it crashes. It wasted two weeks of my time now, I delete every package from the app until getting to backendless. I use 7.2.3 version.
No difference!
No difference:
void initBackend() async {
await Backendless.initApp(
applicationId: Constants.APPLICATION_ID,
androidApiKey: Constants.ANDROID_API_KEY,
iosApiKey: Constants.IOS_API_KEY);
if ((await Backendless.isInitialized())!) {
Backendless.setUrl("https://eu-api.backendless.com");
}
}
I can assume that something is wrong with the gradle
, manifest
or proguard
settings.
Right now we have a BackendlessViewer app on the public google
play and appstore
that uses the backendless_sdk
. Here is it build.gradle
settings:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('app/key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '6'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.2.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false //<- add this line
}
defaultConfig {
applicationId "com.backendless.backendlessViewer"
minSdkVersion 23
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled = true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-core:20.0.0'
}
Try redesigning your gradle
to match the above as closely as possible.
My gradle file is like this: Standard one didn’t change anything.
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 30
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.foroodja.retailers"
minSdkVersion 20
targetSdkVersion 30
multiDexEnabled = true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
dependencies {
implementation("androidx.multidex:multidex:2.0.1")
}
flutter {
source '../..'
}
signingConfig signingConfigs.release
minifyEnabled true
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
add this to
buildTypes{
release{
}
}
Do I need to edit “proguard-android.txt”?
nope
also I don’t see proguard-rules.pro
file in your
android -> app
folder.
Not working.
I saw something in your previous tickets about editing proguard, Are you sure?
proguard-rules.pro
should look like this:
#Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
#Backendless
-dontwarn com.backendless.**
-dontwarn weborb.**
-keep class weborb.** {*;}
-keep class com.backendless.** {*;}
Thank you very much. It is working now.
Please add this to your documents.
Ok, great. Happy Codding:)