3

As activeandroid library suggests, when declaring a model class object to use annotation unique and index annotation parameters for unique constraint and indexing for a column respectively here,

/**activeandroid imports**/
import com.activeandroid.annotation.Column;
import com.activeandroid.Model;
....
@Table(name="Product")
public class Product extends Model{
    ...
    /**issue: index is not a valid parameter for Column annotation**/
    @Column(name = "Category", index = true)
    public String category;
    ...
}

I tried to implement this but the annotation parameters index or unique are not available in the library. I am using version 3.0 jar Tried version3.1 beta also,same issue there. While 3.1 is the latest jar available, am I missing something? Please suggest a solution to create indexes when using activeandroid library. Thanks

  • deleting `.jar` file from `libs` folder and adding `compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'` solved my problem :) – Ali Sherafat Jul 03 '16 at 12:48

1 Answers1

0

Check if you are extending the Model in your Category Class

public class Category extends Model {}

if no, please post the entire Class and Error log.

zhakid
  • 57
  • 7
  • Thanks zhakid, I have done the same. Because IDE does not let me write the index = true as column annotation does not have index parameter available in the activeandroid library. So it doesn't compile. Were you able to set this up successfully? – Gautam Koundinya May 29 '15 at 07:58
  • Hi, yes i was able to do it, do you import the correct annotation? check your imports and let me know. plz edit you question with the class and error log that you have. – zhakid May 30 '15 at 16:25
  • Hi, I am importing com.activeandroid.annotation.Column. Please check the edited question for more details. – Gautam Koundinya May 31 '15 at 18:36
  • see everything alright, try to add the library via Gradle or Maven, i dont know if u are using a wrong Jar. if not plz put the complete error log to see what it happening. – zhakid Jun 01 '15 at 06:48
  • I have tried both of the jar files available here https://github.com/pardom/ActiveAndroid/downloads – Gautam Koundinya Jun 01 '15 at 08:34
  • 1
    That library last update was 2012!!! u are using Android Studio or Eclipse? if android studio in you build.gradle add this dependencies { compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'} – zhakid Jun 01 '15 at 21:11
  • 1
    and delete the jar from the library – zhakid Jun 01 '15 at 22:12
  • if u doesn't use android studio here is the jar http://www.filedropper.com/activeandroid-310-snapshot – zhakid Jun 01 '15 at 22:16
  • Hi, I am using Android Studio. So com.michaelpardo:activeandroid:3.1.0-SNAPSHOT has the updated code? version name is same 3.1.0 though. Will try this solution. Thanks – Gautam Koundinya Jun 04 '15 at 16:17
  • Yes. Try that if it work for you i'll update my answer so u can mark as correct. – zhakid Jun 05 '15 at 18:20
  • same issue... any solution? – Aston Jun 17 '15 at 14:28
  • Aston do you try my approach? – zhakid Jun 17 '15 at 21:42