打包后安装到手机上不显示数据
来源:18-4 打包发布Flutter Android应用-2
慕尼黑3223685
2022-01-03
结果和 https://coding.imooc.com/learn/questiondetail/g5J7RPqEjVNP8Zw1.html 这个问题是一样的 接口是https的 真机调试没问题
手机是Android10 荣耀9x EMUI 是10.1.0
build.gradle 如下
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 plugin: 'kotlin-android’
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
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.trip_app"
// minSdkVersion flutter.minSdkVersion
minSdkVersion 19
targetSdkVersion 30
versionCode 1
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
}
}
}
flutter {
source ‘…/…’
}
dependencies {
implementation “org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version”
}
文档 https://docs.flutter.dev/deployment/android 提示用R8 这边没有用到混淆和压缩
这边Android版本是2020.3.1 Patch4
AndroidSDK 是Android11
页面打印接口信息报错
3回答
-
CrazyCodeBoy
2022-01-06
应该没有网络请求权限导致的加下
<uses-permission android:name="android.permission.INTERNET"/>
可参考下这块课程源码:https://git.imooc.com/coding-321/flutter_trip/src/master/android/app/src/main/AndroidManifest.xml#L800 -
CrazyCodeBoy
2022-01-05
其它接口能正常访问吗
012022-01-05 -
CrazyCodeBoy
2022-01-04
界面上打印下接口返回,看接口有么有调用成功
012022-01-04
相似问题