android - 无法在barcode_scanner颤振中找到明确的活动类
问题描述
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"
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.pwlp"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.pwlp">
<!-- 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. -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Partner Perks"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|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.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.apptreesoftware.barcodescan.BarcodeScannerActivity"/>
</application>
</manifest>
颤振中的条形码扫描仪:-我在颤振中为我的混合应用程序集成了条形码扫描仪。通过遵循这个 git 链接。链接:- https://github.com/apptreesoftware/flutter_barcode_reader
一切顺利。我被安卓应用程序崩溃困住了,
import 'package:flutter/material.dart';
import 'package:barcode_scan/barcode_scan.dart';
import 'package:flutter/services.dart';
import 'dart:async';
class Scanner extends StatefulWidget {
@override
_ScannerState createState() => _ScannerState();
}
class _ScannerState extends State<Scanner> {
String result = "Hey there !";
Future _scanQR() async {
try {
String qrResult = await BarcodeScanner.scan();
setState(() {
result = qrResult;
});
} on PlatformException catch (ex) {
if (ex.code == BarcodeScanner.CameraAccessDenied) {
setState(() {
result = "Camera permission was denied";
print(result);
});
} else {
setState(() {
result = "Unknown Error $ex";
print(result);
});
}
} on FormatException {
setState(() {
result = "You pressed the back button before scanning anything";
print(result);
});
} catch (ex) {
setState(() {
result = "Unknown Error $ex";
print(result);
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text(
result,
style: new TextStyle(fontSize: 30.0, fontWeight: FontWeight.bold),
),
),
floatingActionButton: FloatingActionButton.extended(
icon: Icon(Icons.camera_alt),
label: Text("Scan Now"),
onPressed: _scanQR,
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}
}
我收到一个错误:-
android.content.ActivityNotFoundException:找不到显式活动类 {com.example.pwlp/com.apptreesoftware.barcodescan.BarcodeScannerActivity};您是否在 AndroidManifest.xml 中声明了此活动?
任何建议或我有做其他事情来解决。
请帮忙。谢谢
解决方案
我有同样的问题,我删除了 flutter_app/android/.gradle 文件夹,它对我有用。
推荐阅读
- sql - ORA-00903: 从 USER 中选择时表名无效
- multithreading - Go 内存模型发生在之前(具有共享状态的通道)
- javascript - 使用多重过滤器过滤对象数组
- ios - 录入本地通知后无法在特定视图控制器中打开应用程序
- bash - 用于读取 .csv 文件以创建/移动内容的 Bash 脚本
- java - BigQuery 没有获取在 java 中设置的属性
- java - Eclipse Junit 为 getter 和 setter 正确编写测试
- reactjs - 覆盖的渲染方法上缺少道具类型的 ESLint 错误
- mongodb - mongodb如何使用数组中的元素进行嵌套查询
- android - Kotlin spinners 在片段中使用