【问题标题】:How to install the barcode scanning library without a google account?没有google账号如何安装条码扫描库?
【发布时间】:2016-12-30 09:28:21
【问题描述】:

我想在不允许登录 google 帐户的设备上安装 google play 服务的 android-vision 部分。传统上,通过 play 商店下载 android-vision 库作为 google play 的更新服务。

根据this,包名应该是com.google.android.gms.vision.barcode。我使用 adb 列出了安装在我的根节点设备上的所有包,这些包已经下载了条形码扫描库,并且该包不在列表中。我希望自己拉包然后分发它。

感谢您的时间和精力。

【问题讨论】:

  • 您有没有为此找到解决方案?是否可以在没有 Play 商店帐户的情况下使用 Google Mobile Vision?
  • 你找到解决办法了吗,我也有同样的问题。
  • 检查你的 gradle 缓存,看看它是否在里面。在 \Users\\.gradle\caches\modules-2\files-1\ 有在同步/构建期间缓存的所有 aar。它们按名称组织,例如 com.google.android.gms\play-services-\\
  • 您找到解决方案了吗?我正在编写需要在安全环境中运行的应用程序,在拆箱并由硬件人员保护后,设备必须永远不会连接到互联网。我正在研究使用 Camera2 直接从摄像头获取信息,然后使用 ZBar 进行检测和解码,但事实证明这很棘手。如果我能嵌入视觉库,问题就迎刃而解了。
  • 不幸的是,我们最终放弃了 android-vision 作为一个可行的选择。

标签: android google-play-services barcode barcode-scanner android-vision


【解决方案1】:

第 1 步:尝试将此库包含在基于应用的 gradle 文件中

实现com.google.android.gms:play-services-vision:11.0.2

实现info.androidhive:barcode-reader:1.1.2

第 2 步:通过参考 link 来创建用于扫描的布局

【讨论】:

  • 这无济于事,它只是将视觉条形码库包装在一个易于使用的片段中,它仍然需要有效的互联网连接和一个游戏商店帐户。
【解决方案2】:

您可以使用第三方库实现com.journeyapps:zxing-android-embedded:3.5.0

使用这个库,您也可以轻松集成二维码和条码阅读器,而无需使用谷歌帐户登录。

我的条形码阅读器代码:

    package com.example.elanwrap.qr_code_elan;

    import android.content.Intent;
    import android.net.Uri;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.Toast;
    import com.google.zxing.integration.android.IntentIntegrator;
    import com.google.zxing.integration.android.IntentResult;

    import static android.widget.Toast.LENGTH_LONG;

    public class MainActivity extends AppCompatActivity {

        Button button;
        //CREATING OBJECT
        private IntentIntegrator qrCode;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            button = (Button) findViewById(R.id.button);

            qrCode = new IntentIntegrator(this);

            button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                   //  start the Scan here
                    qrCode.initiateScan();
                }
            });
        }

        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            IntentResult intentResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
            super.onActivityResult(requestCode, resultCode, data);
            if (intentResult != null) {
             //passing result to another Activity.
            //    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(intentResult.getContents() + ""));
                Intent browserIntent = new Intent(this, Result_activity.class );
                browserIntent.putExtra("rah",(intentResult.getContents()+""));
                startActivity(browserIntent);



            } else {
                Toast.makeText(getApplicationContext(), " Empty Result ", Toast.LENGTH_SHORT).show();
            }
        }
    }

和:

package com.example.elanwrap.qr_code_elan;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.TextView;
import android.widget.Toast;

public class Result_activity extends Activity {
    TextView textView;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.result_activity);
        textView=(TextView)findViewById(R.id.details);
        Intent intent = getIntent();
        String str = intent.getStringExtra("rah");
        textView.setText(str);
        Toast.makeText(this, str, Toast.LENGTH_SHORT).show();
    }
}

【讨论】:

  • 是的,但这仍然会启动另一个应用程序,该应用程序会离开当前活动并中断工作流程。我还没有找到我满意的图书馆。我只想要一些将图像格式作为输入并报告结果的东西,以便它可以适应其他人的相机馈送和自定义应用程序。 Google 的视觉 API 我也遇到了问题,因为它在与 SDK 一起分发时需要初始下载。
【解决方案3】:

对于任何谷歌服务,您应该在控制台注册您的添加应用程序。

如果您不想添加您的应用,那么您可以使用任何第三方 API 来获取条形码。

https://github.com/zxing/zxing

【讨论】:

  • 您能解释一下在控制台注册我的应用程序将如何帮助我解决问题吗?
  • 在这里您可以添加谷歌服务条形码,如下 URL:developers.google.com/vision/barcodes-overview 示例代码:github.com/googlesamples/android-vision/tree/master/… 对于谷歌控制台:您需要启用:谷歌云视觉 API,但在此之前您需要添加您的应用程序: console.developers.google.com/apis/dashboard
  • 好的,这不是回答我的问题。 Cloud Vision API 与 android vision API 不同。我也已经有一个使用 API 的工作应用程序。我的问题是如何在没有设备登录谷歌帐户的情况下安装条形码扫描库。
  • 好的,我已经检查了条形码阅读器 api,不需要在谷歌应用程序控制台添加应用程序
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-11-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-21
  • 1970-01-01
相关资源
最近更新 更多