我在实施QR库时遇到问题。
这是我的build.gradle(app)代码:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
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'
implementation 'me.dm7.barcodescanner:zxing:1.9'
}
当我实现'me.dm7.barcodescanner:zxing:1.9'时出现问题 这是我实现
的类public class QRActivity extends AppCompatActivity implements ZXingScannerView.ResultHandler{
private ZXingScannerView zXingScannerView;
TextView txtQRIspis;
Button btnSkeniraj;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.qr_activity);
txtQRIspis = findViewById(R.id.txtQRIspis);
btnSkeniraj = findViewById(R.id.btnSkeniraj);
}
public void skeniraj(View view){
zXingScannerView = new ZXingScannerView(getApplicationContext());
setContentView(zXingScannerView);
zXingScannerView.setResultHandler(this);
zXingScannerView.startCamera();
}
@Override
protected void onPause() {
super.onPause();
zXingScannerView.stopCamera();
}
@Override
public void handleResult(Result result) {
txtQRIspis.setText("Skenirano : " + result.getText());
zXingScannerView.resumeCameraPreview(this);
}
}
我已经尝试过了,但是没有成功: multiDexEnabled在android中为true-defaultConfig。