Open KellydeHaan opened 6 years ago
It would be easier to review if I could see the whole project. In general, you get that exception when the type isn't available (hence the name). In iOS, if you don't add a flag telling the build to include everything, it'll only include classes with hard references. In Java (on the JVM, not J2objc), generics are useful at compile time, but at runtime a List is just a List (basically). It's possible that if the only place you reference Brewery directly by type is the generic param to the List that the Xcode build is stripping that class out.
Having said that, assuming you have a default config in your build gradle, the podspec should include
'OTHER_LDFLAGS' => '-ObjC'
-ObjC tells the linker to include all the classes.
So, basically, I need to see the build.gradle with the j2objcConfig section. I'd also suggest running a full clean and rebuild the pods. It would be easier to debug if you sent the code and I'll take a look.
Thank you for the quick response!
Complete code can be found here: https://github.com/KellydeHaan/BasicAndroidBrewerySample
The reason for two separate Api clients, AlamoFire and Retrofit, is that I ran into a similar issue with Retrofit as I did with Gson: de Retrofit interface could not be found by the Class Loader. But the Gson library is mentioned on the doppl website, and the Retrofit one isn't, so I decided to ask for help here 😄
OK. I got it. The issue is the sample has a path prefix but doesn't include prefix.properties in the Xcode project.
https://developers.google.com/j2objc/guides/package-prefixes
Should be same issue for both problems. The docs need an update. We had docs about that but did a full refresh and not everything made it over (and the sample app should also have Xcode set up properly).
Thank you!
When the iOS application indirectly calls a Gson-method the application crashes with the following exception:
'JavaLangTypeNotPresentException', reason: 'java.lang.TypeNotPresentException: Type com.kgalligan.basicandroid.shared.Brewery not present'
As you can see from the namespace, I added the Brewery.class to the Basic Android Sample from the tutorial on the doppl website.
On Android this code works.
The dependencies on my build.gradle look like this: implementation 'com.google.code.gson:gson:2.6.2' j2objc 'org.j2objcgradle.com.google.code.gson:gson:2.6.2.7'
The code in the original Android file looks like this:
Called like this: new Gson().fromJson(breweries, BreweryResponse.class).getBreweries()
Any suggestions? Thanks in advance!