문제

ActionBarsherlock 및 ViewPagerTab을 사용하는 Android 앱이 하나 있습니다. 나는 Eclipse를 사용하여 작성하고 빌드하며, 개미로 그것을 빌드하려고 할 때까지는 잘 작동합니다. 내가 한 일이있다 :

  1. ActionBarsherLock 폴더로 이동하여 "Android 업데이트 lib-project - 경로"를 실행하십시오.
  2. viewPagerTabs 폴더로 이동하여 "Android 업데이트 lib-project - 경로를 실행하십시오." 너무
  3. 앱 폴더로 이동하여 "Android 업데이트 프로젝트 - 경로"를 실행하십시오.
  4. 앱 폴더에서 "및 디버그"를 실행하고 오류가 있습니다.

    :

    [javac] C:\Android\TestApp\src\com\test\App\TestActivity.java:46: cannot find symbol
    [javac] symbol  : method getSupportActionBar()
    [javac] location: class com.test.App.TestActivity
    [javac]         final ActionBar ab = getSupportActionBar();
    [javac]                              ^
    
    .

    그래서 질문 없음. 1 : 앱의 project.properties에서 올바른 라이브러리 참조가 있고 ActionBarsherlock 및 viewPagerTabs가 성공적으로 구축 될 수 있으므로 왜 이러한 오류가 발생합니까?

    이 문제에 대한 해결 방법은 라이브러리의 bin 폴더에서 모든 classes.jar를 앱의 libs 폴더로 복사하고 "Ant Debug"를 다시 실행하십시오. 그러나 모든 .java 파일 앱을 컴파일 할 수있는 후에 앱의 libs 폴더 에서이 .jar 파일을 삭제해야합니다.

    실행 "Ant Debug"을 다시 실행하면 다음과 같은 후에 오류가 발생합니다.

    [dx] processing archive C:\Android\ActionBarSherlock\library\bin\classes.jar...
    [dx] ignored resource META-INF/MANIFEST.MF
    [dx] processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl.class...
    [dx] processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl.class...
    [dx] processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat.class...
    [dx] processing android/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs.class...
    [dx] processing android/support/v4/app/ActionBar$LayoutParams.class...
    [dx] processing android/support/v4/app/ActionBar$OnMenuVisibilityListener.class...
    [dx] processing android/support/v4/app/ActionBar$OnNavigationListener.class...
    [dx] processing android/support/v4/app/ActionBar$Tab.class...
    [dx] processing android/support/v4/app/ActionBar$TabListener.class...
    [dx] processing android/support/v4/app/ActionBar.class...
    [dx] processing android/support/v4/app/ActivityCompatHoneycomb.class...
    [dx] 
    [dx] UNEXPECTED TOP-LEVEL EXCEPTION:
    [dx] java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActivityCompatHoneycomb;
    [dx]    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
    [dx]    at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
    [dx]    at com.android.dx.command.dexer.Main.processClass(Main.java:486)
    [dx]    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
    [dx]    at com.android.dx.command.dexer.Main.access$400(Main.java:67)
    [dx]    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
    [dx]    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
    [dx]    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
    [dx]    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
    [dx]    at com.android.dx.command.dexer.Main.processOne(Main.java:418)
    [dx]    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
    [dx]    at com.android.dx.command.dexer.Main.run(Main.java:206)
    [dx]    at com.android.dx.command.dexer.Main.main(Main.java:174)
    [dx]    at com.android.dx.command.Main.main(Main.java:95)
    [dx] 1 error; aborting
    
    .

    내 질문 No.2는 다음과 같습니다. 이 문제를 어떻게 수정할 수 있습니까?

    감사합니다!

도움이 되었습니까?

해결책

I finally resolve it myself. I find that there's a android-support-v4.jar in ViewPagerTabs' libs folder. The solution is -- deleting this android-support-v4.jar, then make ViewPagerTabs depend on ActionBarSherlock (because ActionBarSherlock actually have one copy of Support Package).

I hope it's useful for people who wants to use ActionBarSherlock & ViewPagerTabs in one application and use Ant to built his/her application. Good luck.

다른 팁

You stated its because both library have android-support-v4.jar. See @porter-liu answer for non-maven builds.

For people using maven, set your ViewPager dependancy as:

    <dependency>
        <groupId>com.viewpagerindicator</groupId>
        <artifactId>library</artifactId>
        <version>2.4.1</version>
        <type>apklib</type>
        <exclusions>
            <exclusion>
                <groupId>com.google.android</groupId>
                <artifactId>support-v4</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

The exclusion tag stops the double import fixing the issue.

When you update lib-project, you're updating the project so that it compiles as a library. There's a separate step to update your main project so that it sees the library it requires.

For each library project you're going to use, run

android update project --library ../pathToTheLibrary

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top