android - Zxing 在 Android : Eclipse

标签 android

这是我想做的。

我想使用 Zxing 创建一个新的二维码阅读器。

我下载的内容。

Eclipse SDK 经典版本:3.7.0; Android SDK(带有 SDK Tools rev12,以及所有 SDK 平台、API 和示例; Eclipse 中的 ADT 插件(我可以在列表中看到所有 API 的目标:1.5-3.2 和 Google API); Zxing 1.7.

使用。 Windows 7 32 位。

我的环境变量是什么。

ANT_HOME, at (...)\apache-ant-1.8.2
JAVA_HOME, at (...)\jdk1.7.0
PATH, at (...)\jdk1.7.0\bin

我做了什么。

将 Zxing 1.7 提取到 zxing 文件夹中,使用 cmd 成功构建 core.jar(在 (...)\zxing 中键入“ant -f core/build.xml”; 使用 SDK 管理器(Android 1.5 和 Android 2.1)创建了两个 android 虚拟机; 在 Eclipse 属性中设置 SDK Location (C:\PROGRA~1\Android\android-sdk)。 (对不起,如果我错过了什么) 创建一个新的 Android 项目,选择“从现有源创建项目”,使用文件夹 (...)\zxing\android。并选择了 Android 2.1-update1 版本。

在此项目属性中,我在“Java 构建路径”->“库”-> 添加外部 JAR 中添加了文件 core.jar,位于 (...)\zxing\core。

最终,我有以下 src:

`com.google.zxing.client.android
com.google.zxing.client.android.book
com.google.zxing.client.android.camera
com.google.zxing.client.android.encode
com.google.zxing.client.android.history
com.google.zxing.client.android.result
com.google.zxing.client.android.result.supplement
com.google.zxing.client.android.share
com.google.zxing.client.android.wifi`

只有 *.android.camera 似乎可以正常工作;

虽然 AndroidManifest.xml 有一些错误: 在

`<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.google.zxing.client.android"
      android:versionName="3.61 beta 1"
      android:versionCode="71"
      android:installLocation="auto">`

在包“android”中找不到属性“installLocation”的资源标识符

`<supports-screens android:xlargeScreens="true"
                android:largeScreens="true"
                android:normalScreens="true"
                android:smallScreens="true"
                android:anyDensity="true"/>`

在包“android”中找不到属性“xlargeScreen”的资源标识符

因此,我无法构建项目。我能做什么?好像我错误地安装了一些组件(可能是 Android SDK)。有什么提示吗?

在其他方面需要一些帮助。

嗯,如果我设法编译项目,我该如何调用扫描器?

`Bitmap bMap = BitmapFactory.decodeStream(new FileInputStream(file));  
 LuminanceSource source = new RGBLuminanceSource(bMap);
 BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(
                          source));
 Reader reader = new MultiFormatReader();

 Result result = reader.decode(bitmap);`

我怎样才能输出文件?例如,我想处理二维码中包含的信息。我可以输出代码的其他类型的文件是什么?

如何转换 this进图书馆?

如何导入类?我必须将它们包含在 AndroidManifest.xml 中吗?

没看懂:

在您应用的 Eclipse 构建路径中添加 zxing-core 项目的引用,这样它就不会被 JVM 编译。

我找到了其他通过 Intent 输出文件的方法。但是我无法让它工作,因为我需要下载并安装一些文件。它们是什么?

最佳答案

Android 2.1 不支持 xLargeScreens 属性(我认为是 2.2+)。参见 this问题以获取更多信息。

对于 installLocation 属性,您还必须是 2.2 及更高版本 ... 参见 this链接:

Beginning with API Level 8 (2.2), you can allow your application to be installed on the external storage (for example, the device's SD card). This is an optional feature you can declare for your application with the android:installLocation manifest attribute. If you do not declare this attribute, your application will be installed on the internal storage only and it cannot be moved to the external storage.

另外...请将您的问题分成不同的帖子。你首先需要让你的项目运行起来才能问:

“如何调用扫描仪?”
“我怎样才能输出文件?”
“我可以输出代码的其他类型的文件是什么?”
“我怎样才能把它转换成一个库?”
“如何导入类(class)?”
“我找到了其他通过 Intent 输出文件的方法。但我无法让它工作,因为我需要下载和安装一些文件。它们是什么?”

Google 是您的 friend 我的 friend 。在我上过的所有大学类(class)中,我认为 Google 教给我的最多:)。

关于android - Zxing 在 Android : Eclipse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7027635/

相关文章:

android - 重装APP后谷歌APP内购买请求

android - 使用 Cast Companion 库将 HLS 直播流 URL 转换到转换设备

android - HTC One 键盘不改语言,inputType=textVisiblePassword

android - FirebaseInstanceId : Failed to resolve target intent service

Android:慢光传感器(仅在拔下电源时)

android - 当我们从 Android 的外部应用程序手动更改权限时会发生什么

java - 有一个实例变量指向 fragment 内的 Activity 是否安全?

android - 为 ViewPager 小部件动态配置 View ?

android - OnItemClickListener ListView

Android(x,y)连续触摸(拖动)坐标