Ti.SwipeRefreshLayout icon indicating copy to clipboard operation
Ti.SwipeRefreshLayout copied to clipboard

Dexer problem

Open deckameron opened this issue 11 years ago • 10 comments

Raymondkam,

Thank you for sharing this module! Unfortunately I am having problems using it. The error below is showing during compilation.

[ERROR] : Failed to run dexer: [ERROR] :
[ERROR] : UNEXPECTED TOP-LEVEL EXCEPTION: [ERROR] : java.lang.IllegalArgumentException: already added: Landroid/support/v4/content/Loader$OnLoadCompleteListener; [ERROR] : at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122) [ERROR] : at com.android.dx.dex.file.DexFile.add(DexFile.java:161) [ERROR] : at com.android.dx.command.dexer.Main.processClass(Main.java:685) [ERROR] : at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634) [ERROR] : at com.android.dx.command.dexer.Main.access$600(Main.java:78) [ERROR] : at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572) [ERROR] : at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) [ERROR] : at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) [ERROR] : at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) [ERROR] : at com.android.dx.command.dexer.Main.processOne(Main.java:596) [ERROR] : at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498) [ERROR] : at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264) [ERROR] : at com.android.dx.command.dexer.Main.run(Main.java:230) [ERROR] : at com.android.dx.command.dexer.Main.main(Main.java:199) [ERROR] : at com.android.dx.command.Main.main(Main.java:103) [ERROR] : 1 error; aborting [ERROR] Application Installer abnormal process termination. Process exit value was 1

deckameron avatar Aug 18 '14 14:08 deckameron

Hi deckameron,

I couldn't build the module without including the jar into the project, but when I do that it causes the error/conflict you encountered because the android v4 support library jar already exists in the Titanium SDK.

What you have to do is to rename the file android_support-v4.jar to something like android_support-v4-disabled.jar located in the Titanium SDK in the folder below (OS X) /Users/(your username)/Library/Application Support/Titanium/mobilesdk/osx/(your titanium version)/android/

I will update the README to include this.

raymondkam avatar Aug 18 '14 15:08 raymondkam

@raymondkam Thank you for reply! I have tried what you asked and unfortunately it didn't work for me. I am using Windows 7 and Titanium SDK 3.3.0. If I use the module on my project I stops working and give the a black screen with the message "[App] stopped". Do you know what could be causing this issue? Could post a full working example inside with dist example folder, please?

deckameron avatar Aug 25 '14 22:08 deckameron

Solution is very simple, just delete 'lib/android-support-v4.jar' from the project & distribution package both. It builds perfectly & distribution package works properly with the target project.

NOTE : Don't rename android_support-v4.jar at following path, because it may be used by some internal Titanium code or some other native modules.

/Users/(your username)/Library/Application Support/Titanium/mobilesdk/osx/(your titanium version)/android/

vatsalengg avatar Aug 26 '14 08:08 vatsalengg

@vatsalengg thank you for you help. I have just tried it and it compiles ok but my application crashes when creating the refresh control.

Error: android.view.InflateException: Binary XML file line #1: Error inflating class com.rkam.swiperefreshlayout.MySwipeRefreshLayout

I am posting my code here:

    var swipeRefreshModule = require('com.rkam.swiperefreshlayout');

    var window = Titanium.UI.createWindow({
    backgroundColor: '#F2F2F2',
    fullscreen: false
});

    var tableView = Titanium.UI.createTableView({
    scrollsToTop: true,
    backgroundColor: 'transparent',
    minRowHeight: '80',
    top: '60',
    bottom: '0',
    separatorStyle: Titanium.UI.iPhone.TableViewSeparatorStyle.SINGLE_LINE
});

var swipeRefresh = swipeRefreshModule.createSwipeRefresh({
    view: tableView,
    top: '60',
    bottom: '0'
});
window.add(swipeRefresh);
    window.open();

deckameron avatar Aug 26 '14 12:08 deckameron

@deckameron You have to include following jar in your project's build path (android-sdk-path-here)/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0.jar

This will surely compile & work properly, I am using this method & used generated build in other project.

vatsalengg avatar Aug 26 '14 12:08 vatsalengg

@vatsalengg Thanks for figuring it out. I was suspecting that the jar included with the dist could be removed but I never had a chance to test it. I did need to include the jar within the project to build the module.

Edit: How did you add the jar to the project's build path? Is project referring to the Titanium project?

raymondkam avatar Aug 26 '14 14:08 raymondkam

@vatsalengg I am not sure I understood what you said. I have to copy the (android-sdk-path-here)/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0.jar file to my projects build folder, along with Android and Iphone folders?

deckameron avatar Aug 26 '14 15:08 deckameron

Hi @deckameron, sorry I misunderstood. Actually you have to build the module by yourself. Follow the below given steps to build & prevent the error mentioned by you.

  • Download source of this module.
  • Then in that source project, change paths in build.properties file to your relevant system paths.
  • Then change minsdk to 3.3.0.GA in manifest file.
  • Open Project's Java Build Path by right click > properties > Java Build Path, select Libraries tab.
  • In that, change project's Java Build Paths' jars relevant paths in .
  • Then, you have to add following jar in build path of project.

(android-sdk-path-here)/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0.jar

  • Delete 'lib/android-support-v4.jar'. Also, delete the same from distribution package's folder.

Thus, after clearing all errors in project, you should build this module & place distribution package in desired target project.

This method is working fine for me.

@raymondkam, I could not understand the reason of conflict with android-support-v4.jar. In native android Java, if you develop library project (similar to module in titanium), then duplicate inclusion of android-support-v4.jar is properly handled by Android Development Toolkit plugin to prevent this error.

There should be better way in Titanium to handle this duplicate jar inclusion issue.

vatsalengg avatar Aug 27 '14 06:08 vatsalengg

@raymondkam why don't you provide distributions with the android-support-v4 jar taken out?

FokkeZB avatar Oct 13 '14 06:10 FokkeZB

@FokkeZB Hey sorry I recently changed dev environments from a Mac to Windows and I couldn't get it working on my desktop. I just got my laptop setup and now I can build. I can finally address this issue and the one about setting colours dynamically.

raymondkam avatar Oct 13 '14 23:10 raymondkam