我正在使用
implementation ('com.journeyapps:zxing-android-embedded:3.6.0') { transitive = false }
implementation 'com.google.zxing:core:3.3.0'
我一切正常。我可以构建签名的APK并从Android Studio中运行它们。我可以在模拟器和真实设备上运行项目。一切正常。
但是我试图在此项目上设置Fastlane,因此我需要运行gradle assembleRelease
。多数民众赞成在我遇到标题错误时。
Android资源链接失败 /home/cescoferraro/go/src/github.com/onnidev/astaff/base/build/intermediates/merged_manifests/releaseFeature/AndroidManifest.xml:118:AAPT:错误:资源样式/ zxing_CaptureTheme(又名live.onni.astaff.app :找不到style / zxing_CaptureTheme。
这就是我开始扫描过程的方式,我使用的是customActivity,因此我可以在相机屏幕上设置闪光灯按钮
override fun scan() {
IntentIntegrator(this@DashboardActivity)
.setCaptureActivity(QRCodeScannerActivity::class.java)
.setOrientationLocked(false)
.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE)
.initiateScan()
}
我在清单上声明了这样的活动
<activity
android:name=".dashboard.QRCodeScannerActivity"
android:screenOrientation="portrait" />
如果我碰巧将zxing主题添加到活动中。我两次看到错误
<activity
android:theme="@style/zxing_CaptureTheme"
android:name=".dashboard.QRCodeScannerActivity"
android:screenOrientation="portrait" />
Android资源链接失败/home/cescoferraro/go/src/github.com/onnidev/astaff/base/build/intermediates/merged_manifests/releaseFeature/AndroidManifest.xml:91:AAPT:错误:资源样式/ zxing_CaptureTheme(又名找不到live.onni.astaff.app:style/zxing_CaptureTheme)。 /home/cescoferraro/go/src/github.com/onnidev/astaff/base/build/intermediates/merged_manifests/releaseFeature/AndroidManifest.xml:119:AAPT:错误:资源样式/ zxing_CaptureTheme(又名live.onni.astaff.app :找不到style / zxing_CaptureTheme。
自定义活动扫描程序代码如下
QRCodeScannerActivity类:CaptureActivity(),DecoratedBarcodeView.TorchListener {
private var capture: CaptureManager? = null
private var barcodeScannerView: DecoratedBarcodeView? = null
private var switchFlashlightButton: Button? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_custom_scanner)
barcodeScannerView = findViewById<View>(R.id.zxing_barcode_scanner) as DecoratedBarcodeView
barcodeScannerView!!.setTorchListener(this)
switchFlashlightButton = findViewById<View>(R.id.switch_flashlight) as Button
if (!hasFlash()) {
switchFlashlightButton!!.visibility = View.GONE
}
capture = CaptureManager(this, barcodeScannerView!!)
capture!!.initializeFromIntent(intent, savedInstanceState)
capture!!.decode()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
super.onActivityResult(requestCode, resultCode, data)
val result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data)
Log.i(" whatever", result.contents)
}
override fun onResume() {
super.onResume()
capture!!.onResume()
}
override fun onPause() {
super.onPause()
capture!!.onPause()
}
override fun onDestroy() {
super.onDestroy()
capture!!.onDestroy()
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
this.capture!!.onSaveInstanceState(outState)
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
return barcodeScannerView!!.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event)
}
private fun hasFlash(): Boolean {
return applicationContext.packageManager
.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)
}
fun switchFlashlight(view: View) {
println(view.alpha)
if (this.getString(R.string.turn_on_flashlight)!!.contentEquals(switchFlashlightButton!!.text)) {
barcodeScannerView!!.setTorchOn()
} else {
barcodeScannerView!!.setTorchOff()
}
}
override fun onTorchOn() {
switchFlashlightButton!!.setText(R.string.turn_off_flashlight)
}
override fun onTorchOff() {
switchFlashlightButton!!.setText(R.string.turn_on_flashlight)
}
}
答案 0 :(得分:0)
您可以在仓库zxing-android-embedded/zxing-android-embedded中找到缺少的样式
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="zxing_CaptureTheme" parent="android:Theme.Holo.NoActionBar.Fullscreen">
</style>
</resources>
我已将样式手动添加到现有文件base / res / values / styles.xml:
这为我解决了。