使用maven将android facebook sdk打包为apklib

发布于 2024-12-05 12:35:42 字数 6681 浏览 1 评论 0 原文

我已经使用 maven-android-plugin 3.0.0-alpha-7 将 facebook android sdk 打包为 apklib。它看起来像这样:

    $ unzip sdk-1.0-SNAPSHOT.apklib
    Archive:  sdk-1.0-SNAPSHOT.apklib
   creating: META-INF/
  inflating: META-INF/MANIFEST.MF    
  inflating: AndroidManifest.xml     
   creating: assets/
   creating: res/
   creating: res/drawable/
   creating: res/drawable-hdpi/
   creating: res/drawable-ldpi/
  inflating: res/drawable/facebook_icon.png  
  inflating: res/drawable-hdpi/facebook_icon.png  
  inflating: res/drawable-ldpi/facebook_icon.png  
   creating: src/
   creating: src/com/
   creating: src/com/facebook/
   creating: src/com/facebook/android/
  inflating: src/com/facebook/android/AsyncFacebookRunner.java  
  inflating: src/com/facebook/android/DialogError.java  
  inflating: src/com/facebook/android/Facebook.java  
  inflating: src/com/facebook/android/FacebookError.java  
  inflating: src/com/facebook/android/FbDialog.java  
  inflating: src/com/facebook/android/Util.java  

然后我将它安装到我的项目的本地存储库中,并将其作为 Maven 依赖包含...并运行构建我得到:

$ mvn clean package android:deploy
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building myproject 2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ myproject-android ---
[INFO] Deleting /Users/user/dev/projects/company/myproject-android/target
[INFO] 
[INFO] --- maven-android-plugin:3.0.0-alpha-7:generate-sources (default-generate-sources) @ myproject-android ---
[DEBUG] Expanding: /Users/user/.m2/repository/com/facebook/android/sdk/1.0-SNAPSHOT/sdk-1.0-SNAPSHOT.apklib into /Users/user/dev/projects/company/myproject-android/target/unpack/apklibs/com.facebook.android_sdk_apklib_1.0-SNAPSHOT
[DEBUG] expand complete
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] /Users/user/dev/libs/android-sdk-mac_x86/platform-tools/aapt [package, -m, -J, /Users/user/dev/projects/company/myproject-android/target/generated-sources/r, -M, /Users/user/dev/projects/company/myproject-android/AndroidManifest.xml, -S, /Users/user/dev/projects/company/myproject-android/res, -S, /Users/user/dev/projects/company/myproject-android/target/unpack/apklibs/com.facebook.android_sdk_apklib_1.0-SNAPSHOT/res, --auto-add-overlay, -A, /Users/user/dev/projects/company/myproject-android/assets, -I, /Users/user/dev/libs/android-sdk-mac_x86/platforms/android-10/android.jar]
[INFO] /Users/user/dev/libs/android-sdk-mac_x86/platform-tools/aapt [package, -m, -J, /Users/user/dev/projects/company/myproject-android/target/generated-sources/r, --custom-package, com.facebook, -M, /Users/user/dev/projects/company/myproject-android/AndroidManifest.xml, -S, /Users/user/dev/projects/company/myproject-android/res, -S, /Users/user/dev/projects/company/myproject-android/target/unpack/apklibs/com.facebook.android_sdk_apklib_1.0-SNAPSHOT/res, --auto-add-overlay, -A, /Users/user/dev/projects/company/myproject-android/assets, -A, /Users/user/dev/projects/company/myproject-android/target/unpack/apklibs/com.facebook.android_sdk_apklib_1.0-SNAPSHOT/assets, -I, /Users/user/dev/libs/android-sdk-mac_x86/platforms/android-10/android.jar]
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ myproject-android ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/user/dev/projects/company/myproject-android/src/main/resources
[INFO] skip non existing resourceDirectory /Users/user/dev/projects/company/myproject-android/target/generated-sources/extracted-dependencies/src/main/resources
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ myproject-android ---
[INFO] Compiling 141 source files to /Users/user/dev/projects/company/myproject-android/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /Users/user/dev/projects/company/myproject-android/target/unpack/apklibs/com.facebook.android_sdk_apklib_1.0-SNAPSHOT/src/com/facebook/android/FbDialog.java:[95,17] package R does not exist
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Skipping myproject
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.279s
[INFO] Finished at: Wed Sep 21 09:32:40 PDT 2011
[INFO] Final Memory: 13M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project myproject-android: Compilation failure
[ERROR] /Users/user/dev/projects/company/myproject-android/target/unpack/apklibs/com.facebook.android_sdk_apklib_1.0-SNAPSHOT/src/com/facebook/android/FbDialog.java:[95,17] package R does not exist
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

我看到 R 文件正在生成并具有正确的内容:

$ find target/generated-sources/r/
target/generated-sources/r/
target/generated-sources/r//com
target/generated-sources/r//com/facebook
target/generated-sources/r//com/facebook/Manifest.java
target/generated-sources/r//com/facebook/R.java
target/generated-sources/r//com/company
target/generated-sources/r//com/company/myproject
target/generated-sources/r//com/company/myproject/droid
target/generated-sources/r//com/company/myproject/droid/Manifest.java
target/generated-sources/r//com/company/myproject/droid/R.java

什么是我缺少将 R 文件包含在编译步骤中吗?

I have used maven-android-plugin 3.0.0-alpha-7 to package the facebook android sdk as a apklib. It looks like this:

    $ unzip sdk-1.0-SNAPSHOT.apklib
    Archive:  sdk-1.0-SNAPSHOT.apklib
   creating: META-INF/
  inflating: META-INF/MANIFEST.MF    
  inflating: AndroidManifest.xml     
   creating: assets/
   creating: res/
   creating: res/drawable/
   creating: res/drawable-hdpi/
   creating: res/drawable-ldpi/
  inflating: res/drawable/facebook_icon.png  
  inflating: res/drawable-hdpi/facebook_icon.png  
  inflating: res/drawable-ldpi/facebook_icon.png  
   creating: src/
   creating: src/com/
   creating: src/com/facebook/
   creating: src/com/facebook/android/
  inflating: src/com/facebook/android/AsyncFacebookRunner.java  
  inflating: src/com/facebook/android/DialogError.java  
  inflating: src/com/facebook/android/Facebook.java  
  inflating: src/com/facebook/android/FacebookError.java  
  inflating: src/com/facebook/android/FbDialog.java  
  inflating: src/com/facebook/android/Util.java  

I then install it into a local repo for my project and include it as a maven dep... and run the build I get this:

$ mvn clean package android:deploy
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building myproject 2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ myproject-android ---
[INFO] Deleting /Users/user/dev/projects/company/myproject-android/target
[INFO] 
[INFO] --- maven-android-plugin:3.0.0-alpha-7:generate-sources (default-generate-sources) @ myproject-android ---
[DEBUG] Expanding: /Users/user/.m2/repository/com/facebook/android/sdk/1.0-SNAPSHOT/sdk-1.0-SNAPSHOT.apklib into /Users/user/dev/projects/company/myproject-android/target/unpack/apklibs/com.facebook.android_sdk_apklib_1.0-SNAPSHOT
[DEBUG] expand complete
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] /Users/user/dev/libs/android-sdk-mac_x86/platform-tools/aapt [package, -m, -J, /Users/user/dev/projects/company/myproject-android/target/generated-sources/r, -M, /Users/user/dev/projects/company/myproject-android/AndroidManifest.xml, -S, /Users/user/dev/projects/company/myproject-android/res, -S, /Users/user/dev/projects/company/myproject-android/target/unpack/apklibs/com.facebook.android_sdk_apklib_1.0-SNAPSHOT/res, --auto-add-overlay, -A, /Users/user/dev/projects/company/myproject-android/assets, -I, /Users/user/dev/libs/android-sdk-mac_x86/platforms/android-10/android.jar]
[INFO] /Users/user/dev/libs/android-sdk-mac_x86/platform-tools/aapt [package, -m, -J, /Users/user/dev/projects/company/myproject-android/target/generated-sources/r, --custom-package, com.facebook, -M, /Users/user/dev/projects/company/myproject-android/AndroidManifest.xml, -S, /Users/user/dev/projects/company/myproject-android/res, -S, /Users/user/dev/projects/company/myproject-android/target/unpack/apklibs/com.facebook.android_sdk_apklib_1.0-SNAPSHOT/res, --auto-add-overlay, -A, /Users/user/dev/projects/company/myproject-android/assets, -A, /Users/user/dev/projects/company/myproject-android/target/unpack/apklibs/com.facebook.android_sdk_apklib_1.0-SNAPSHOT/assets, -I, /Users/user/dev/libs/android-sdk-mac_x86/platforms/android-10/android.jar]
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ myproject-android ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/user/dev/projects/company/myproject-android/src/main/resources
[INFO] skip non existing resourceDirectory /Users/user/dev/projects/company/myproject-android/target/generated-sources/extracted-dependencies/src/main/resources
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ myproject-android ---
[INFO] Compiling 141 source files to /Users/user/dev/projects/company/myproject-android/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /Users/user/dev/projects/company/myproject-android/target/unpack/apklibs/com.facebook.android_sdk_apklib_1.0-SNAPSHOT/src/com/facebook/android/FbDialog.java:[95,17] package R does not exist
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Skipping myproject
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.279s
[INFO] Finished at: Wed Sep 21 09:32:40 PDT 2011
[INFO] Final Memory: 13M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project myproject-android: Compilation failure
[ERROR] /Users/user/dev/projects/company/myproject-android/target/unpack/apklibs/com.facebook.android_sdk_apklib_1.0-SNAPSHOT/src/com/facebook/android/FbDialog.java:[95,17] package R does not exist
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

I see the R files are getting generated and have the correct contents:

$ find target/generated-sources/r/
target/generated-sources/r/
target/generated-sources/r//com
target/generated-sources/r//com/facebook
target/generated-sources/r//com/facebook/Manifest.java
target/generated-sources/r//com/facebook/R.java
target/generated-sources/r//com/company
target/generated-sources/r//com/company/myproject
target/generated-sources/r//com/company/myproject/droid
target/generated-sources/r//com/company/myproject/droid/Manifest.java
target/generated-sources/r//com/company/myproject/droid/R.java

What am I missing to get the R files included in the compilation step?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪推晚风 2024-12-12 12:35:42

我已经为您做到了:https://github.com/casidiablo/android-facebook

下载

可用的最新版本是1.5

Maven

您可以通过包含此依赖项和存储库从 Maven 使用它:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    ...
    <dependencies>
        ...
        <dependency>
            <groupId>com.codeslap</groupId>
            <artifactId>android-facebook</artifactId>
            <version>1.6</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>codeslap</id>
            <url>http://casidiablo.github.com/codeslap-maven/repository/</url>
        </repository>
    </repositories>
</project>

I already did that for you: https://github.com/casidiablo/android-facebook

Download

Latest version available is 1.5:

Maven

You can use it from Maven by including this dependency and repository:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    ...
    <dependencies>
        ...
        <dependency>
            <groupId>com.codeslap</groupId>
            <artifactId>android-facebook</artifactId>
            <version>1.6</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>codeslap</id>
            <url>http://casidiablo.github.com/codeslap-maven/repository/</url>
        </repository>
    </repositories>
</project>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文