我正在尝试使用local_auth,从0.4.0更新到0.6.2
我按照说明操作,在MainActivity.java中将FlutterActivity更改为FlutterFragmentActivity
(根据本指南https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects用这根线https://github.com/flutter/flutter/issues/57678)
这样
import io.flutter.embedding.android.FlutterFragmentActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.embedding.engine.FlutterEngine;
public class MainActivity extends FlutterFragmentActivity {
@Override
public void configureFlutterEngine(FlutterEngine flutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
我还更改了style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
</resources>
和我的AndroidManifest.xml
<application
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:fullBackupContent="false"
android:label="XXX">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.apptreesoftware.barcodescan.BarcodeScannerActivity"/>
<provider
android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
android:authorities="${applicationId}.flutter_downloader.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
它适用于Android 28及更高版本,但不适用于旧版本。
当我在android 27上运行时,我得到了这个错误
I/合子(10611):拒绝对以前失败的类java.lang.class:java.lang.NoClassDefFoundError:未能解析:Landroidx/core/widget/TintableComponentDrawablesView;I/合子(10611):(可抛出,无堆栈跟踪)I/合子(106.11):原因:java.lang.ClassNotFoundException:在路径DexPathList上找不到类"androidx.core.widget.TintableCompoundDrawablesView"[[zip file"/data/app/it.xxx.flatter.xxxx-bwyNjP_RiFiWr_SW3gO7MQ==/base.apk"],nativeLibraryDirectories=[/data/app/it.xxx.flaton.xxx-bwyNjP_RiFiWr_SW3gO7MQ==/lib/x86,/data/app/itxxx.flaton.xxx-bwyNjP_RiFiWr_SW3gO7MQ==/base.apk!/lib/x86、/system/lib、/vvendor/lib]]I/合子(10611 plugins.flutter.io/local_auth(10611):android.view.InflateException:二进制XML文件行#26:Binary XML文件行#45:膨胀类androidx.appcompat.widget.DialogTitle E/MethodChannel#plugins.flutter.io/local_auth(10611)时出错:由以下原因引起:android.vview.InflateException:二进制XML文件列#45:充气类androidx.appcompat.idt.DialogTitle E/MethodChannel#plugins.fflutter.io/local_authjava.lang.ClassNotFoundException:androidx.appcompat.idget.DialogTitle E/MethodChannel#plugins.flutter.io/local_auth(10611):在java.lang.VMClassLoader.findLoadedClass(Native Method)E/MethodChannel#plugins.fflutter.io/local_auth(ClassLoader.java:363)E/MethodChannel#plugins.flutter.io/local_auth(10611):在java.lang.ClassLoader.loadClass(ClassLoader:java:312)E/MethodChannel#plugins.flutter.io/local_authE/MethodChannel#plugins.flutter.io/local_auth(10611):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)E/MethodChannel#plugins.fflutter.io/local_authE/MethodChannel#plugins.flutter.io/local_auth(10611):在android.view.LayoutInflater.rInflate(LayoutInflater.java:866)E/MethodChannel#plugins.fflutter.io/local_authE/MethodChannel#plugins.flutter.io/local_auth(10611):在android.view.LayoutInflater.rInflate(LayoutInflater.java:859)E/MethodChannel#plugins.fflutter.io/local_authE/MethodChannel#plugins.flutter.io/local_auth(10611):在android.view.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDeleateImpl.java:555)E/MethodChannel#plugins.flutter.io/local_auth(10611):在androidx.appcompat.app.AppCompatDialog.setContentView(AppCompatDialog.java:95)E/MethodChannel#plugins.fflutter.io/local_authE/MethodChannel#plugins.flutter.io/local_auth(10611):在android.app.Dialog.dispatchOnCreate(Dialog.java:403)E/MethodChannel#plugins.fflutter.io/local_authandroidx.fragment.app.fragment.performStart(fragment.java:2632)E/MethodChannel#plugins.flutter.io/local_auth(10611):在androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:915)E/MethodChannel#plugins.flutter.io/local_authE/MethodChannel#plugins.flutter.io/local_auth(10611):在androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)E/MethodChannel#plugins.fflutter.io/local_auth
E/MethodChannel#plugin.flutter.io/local_auth(10611):…44更多
这是我的配置
[✓] Flutter: is fully installed. (Channel stable, v1.17.3, on Mac OS X 10.15.5 19F101, locale en-IT)
[✓] Android toolchain - develop for Android devices: is fully installed. (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS: is fully installed. (Xcode 11.5)
[✓] Android Studio: is fully installed. (version 3.6)
[✓] VS Code: is fully installed. (version 1.45.1)
[✓] Connected device: is fully installed. (1 available)
如有任何建议,将不胜感激
帮助我:
活动
导入io.flutter.embedding.android.FlutterActivity
类MainActivity:FlutterActivity(){}
清单
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="your label"
android:icon="@mipmap/ic_launcher">
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!-- The Agora SDK requires Bluetooth permissions in case users are using Bluetooth devices.-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
我可能迟到了,但今天我遇到了同样的问题,对我来说,遵循这个解决方案很有用
https://github.com/hnvn/flutter_image_cropper/issues/78
拆除这些部件
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx') ) {
details.useVersion "1.0.1"
}
if (requested.group == "androidx") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "${targetSdk}.+"
}
来自Android/build.gradle
我解决了我的问题。。。
我删除了
if (
details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')
) {
details.useVersion "27.1.1"
}
if (
details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx')
) {
details.useVersion "1.0.1"
}
if (requested.group == "androidx" && !requested.name.startsWith("multidex")) {
details.useVersion "${targetSdk}.+"
}
来自android/build.gradle
并且它工作于