如何导入ZXING到Android工作室? [英] How to import ZXING to android studio?

查看:406
本文介绍了如何导入ZXING到Android工作室?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Android工作室
我想在我的应用程序中导入ZXING',我发现很多文章,发现以下网站

https://github.com/zxing/zxing/

我下载的压缩和解压缩,并找到了一些教程
但它似乎并没有被说的太详细的细节,我需要进口?为了实现QR code扫描

我仍然不知道该怎么做。


4/14
我试图侬提供的网址
zxing-Android的最低
并导入gradle这个-wrapper.jar

但是,当我写的
新IntentIntegrator(本).initiateScan();
仍然会出现无法解析符号'IntentIntegrator消息

<一个href=\"https://www.dropbox.com/s/2srga9iq75iqe4m/%E8%9E%A2%E5%B9%95%E6%88%AA%E5%9C%96%202015-04-10%2001.33.56.png?dl=0\">https://www.dropbox.com/s/2srga9iq75iqe4m/%E8%9E%A2%E5%B9%95%E6%88%AA%E5%9C%96%202015-04-10%2001.33.56.png?dl=0

我有一个正确的的.jar选择添加库
但是,当发生错误时,他似乎没有被添加


4/10

终于不再出现无法解析符号'IntentIntegrator
这是code,什么我错了?

我删除了新IntentIntegrator(本).initiateScan(); 应用程序正常运行。

  @覆盖
保护无效的onCreate(捆绑savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.activity_main);
    新IntentIntegrator(本).initiateScan();
}

我的'build.greadle

  {库
    jcenter()
    行家{
        网址https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/
    }
}


解决方案

我有很多的麻烦,当我使用zxing库开发我的应用程序。所以来看看这个zxing最小: https://github.com/Promptus/zxing -Android-最小/树/主

它的工作完美的我,是更容易实现。

编辑:

在项目中打开这个文件:

/gradle/wrapper/gradle-wrapper.properties

编辑distributionUrl线并设置它太:

distributionUrl = HTTP://services.gradle.org/distributions/gradle-1.8-all.zip
重新生成项目。

更新:您可能想现在使用gradle-2.1-all.zip

新的编辑:

首先,您必须删除你的文件。然后,你必须删除

  mavenCentral()
    行家{
        网址https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/
    }

的build.gradle 所有MyApplication ,因为那是的gradle为整个项目,而且最好你使用它的每个模块中的

在此之后,打开的build.gradle 模块的应用并添加下列code:

  {库
    mavenCentral()    行家{
        网址https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/
    }
}依赖{
    编译文件树(导演:'库',包括:['的* .jar'])
    编译com.android.support:appcompat-v7:21.0.3    // Zxing库
    编译com.embarkmobile:zxing-Android的最小:2.0.0@aar
    编译com.embarkmobile:zxing-Android的整合:2.0.0@aar
    编译com.google.zxing:核心:3.0.1}

最后,你需要从你的项目中删除 google.zxing.integration.android ,否则,错误将显示,当你编译。

更新:

要解决后退按钮的问题,你可以做以下code:

  @覆盖
保护无效的onActivityResult(INT申请code,INT结果code,意图数据){
    super.onActivityResult(要求code,结果code,数据);    如果(结果code == RESULT_OK){        字符串_ code = data.getStringExtra(SCAN_RESULT);        // 做你想做的    }}

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

https://github.com/zxing/zxing/

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

https://www.dropbox.com/s/2srga9iq75iqe4m/%E8%9E%A2%E5%B9%95%E6%88%AA%E5%9C%96%202015-04-10%2001.33.56.png?dl=0

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

    }

}

这篇关于如何导入ZXING到Android工作室?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆