birajpatel / EasyListViewAdapters

This library provides Easy Android ListView Adapters(EasyListAdapter & EasyCursorAdapter) which makes designing Multi-Row-Type ListView very simple & cleaner, It also provides many useful features for ListView.
Other
129 stars 31 forks source link

Application specific R import in com.birin.easylistviewadapters.utils.ChildViewsClickHandler #2

Closed PulfordJ closed 9 years ago

PulfordJ commented 9 years ago

After importing via the repo I get:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/birin/easylistviewadapters/R$string;

The build script does not appear to successfully generate the R.java file.

After importing manually as a package I was able to get further information on this.

File com.birin.easylistviewadapters.utils.ChildViewsClickHandler contains:

import com.birin.easylistviewadapters.R;

Which means importing via Gradle will cause an error (at least when the child on click handler functionality is used). It appears to require this import for

private static int TAG_VIEW_POSITION = R.string.key_view_position;
private static int TAG_CLICK_EVENT_ID = R.string.key_click_event_id;

When setting these to 0 I get:

The key must be an application-specific resource id.

Caused by the setTag line in the last method:

  private static void tagIntValueToView(View view, int key, int value) {
        if (null != view) {
            view.setTag(key, value);
        }
    }

http://stackoverflow.com/questions/2859574/the-key-must-be-an-application-specific-resource-id seems to suggest no work around, an easy fix is to add as a package and change the import line and add https://github.com/birajpatel/EasyListViewAdapters/blob/master/EasyListViewAdapters/easylistviewadapters/src/main/res/values/dummy_ids.xml .

I feel it should be importable via Gradle somehow, perhaps the user could supply these values in a higher class? I think the best solution would be for the build script could be built to successfully include R.java. (https://github.com/rey5137/material is an example library that achieves this) After digging around I feel this is easier for someone who is more familiar with the build script to fix so I just thought I'd notify you guys in the hopes you keep up the great work! :)

birajpatel commented 9 years ago

Could you tell me the fix, I am not aware smart in build scripts. Yes, as you suggested : "I think the best solution would be for the build script could be built to successfully include R.java" Can you suggest the changes??? or Raise the PR??

PulfordJ commented 9 years ago

I looked into this a bit more and when building with

gradlew clean easylistviewadapters:assembleDebug

from folder https://github.com/birajpatel/EasyListViewAdapters/tree/master/EasyListViewAdapters the resulting aar file http://tools.android.com/tech-docs/new-build-system/aar-format successfully includes the R.java . I suspect assembleRelease will do the same but I'm uncertain how you upload that.

birajpatel commented 9 years ago

I uploaded my AAR file binTray by defining upload related info in : https://github.com/birajpatel/EasyListViewAdapters/blob/master/EasyListViewAdapters/easylistviewadapters/build.gradle

I run below command to Upload ./gradew bintrayUpload

Please refer the link where I learnt about AAR creation & upload .

https://www.virag.si/2015/01/publishing-gradle-android-library-to-jcenter/

birajpatel commented 9 years ago

Hey, I just checked ... Steps 1) In my live project I imported my lib using Maven import 2) Used it my app. 3) Also used child click view functionality 4) works well in RELEASE build as well,even with progaurd enabled

I think you are making some mistake in importing it.

Please tell me exact steps to produce the crash you are mentioning.

PulfordJ commented 9 years ago

I'm on a separate PC but with the same code base and am embarrassingly unable to reproduce the error. Probably human error or something to do with the system, will close, my bad!