如何把zxing导入java,如何导入ZXING到Android工作室?

I use android studio

I want to import 'ZXING' in my application, I find many articles and found the following site

I downloaded the ZIP and unzip, and find some tutorials

But it does not seem to be too detailed about the details, what I need to import? To achieve QRCode scan

I still have no idea how to do it

4/14

I tried Lennon URL provided

"zxing-android-minimal"

And import the 'gradle-wrapper.jar'

But when I wrote

new IntentIntegrator (this) .initiateScan ();

Still appear "Can not resolve symbol 'IntentIntegrator" message

I do have a right '.jar select Add As Library

But when an error occurs, he does not seem to be added

4/10

Finally no longer appear "Can not resolve symbol 'IntentIntegrator"

this is the code,What do I wrong?

I removed the new IntentIntegrator (this) .initiateScan (); 'applications normal operation

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

new IntentIntegrator(this).initiateScan();

}

my 'build.greadle'

repositories {

jcenter()

maven {

url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/"

}

}

解决方案

I had many troubles when I developed my app using zxing library. So take a look this zxing minimal: https://github.com/Promptus/zxing-android-minimal/tree/master

It worked perfectly to me and was easier to implement.

EDIT:

Open up this file in your project:

/gradle/wrapper/gradle-wrapper.properties

Edit the distributionUrl line and set it too:

distributionUrl=http://services.gradle.org/distributions/gradle-1.8-all.zip

Rebuild your project.

Update: You might want to use gradle-2.1-all.zip now.

NEW EDIT:

First of all, you must remove your libs file. Then you have to remove

mavenCentral()

maven {

url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/"

}

from your build.gradle of MyApplication, because that gradle is for the whole project, and it's better you use it in each module.

After that, open the build.gradle of the module app and add the following code:

repositories {

mavenCentral()

maven {

url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/"

}

}

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:21.0.3'

// Zxing libraries

compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar'

compile 'com.embarkmobile:zxing-android-integration:2.0.0@aar'

compile 'com.google.zxing:core:3.0.1'

}

And finally, you need to delete google.zxing.integration.android from your project, otherwise, an error will show up when you compile.

UPDATE:

To resolve the back button problem, you can do the following code:

@Override

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

super.onActivityResult(requestCode, resultCode, data);

if (resultCode == RESULT_OK) {

String _code = data.getStringExtra("SCAN_RESULT");

// do whatever you want

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值