android-dts-generator icon indicating copy to clipboard operation
android-dts-generator copied to clipboard

Input aar file type support

Open roblav96 opened this issue 9 years ago • 5 comments

How would I go about using an aar file instead of jar? I'd like to input play-services-maps-9.4.0.aar into the dts-generator.

roblav96 avatar Aug 28 '16 17:08 roblav96

@roblav96 for the time being you can extract the classes.jar from the .aar and pass it as a parameter to the generator. Feel free to rename the .jar to whatever you feel like to avoid naming conflicts.

petekanev avatar Sep 30 '16 14:09 petekanev

@roblav96 A little unrelated to the issue, but thought it's worth sharing - I tried inputting as many jars and aars into the generator and it kind of... worked. Due to limitations in TypeScript and JavaScript modules (namespaces) that contain .android. anywhere in the namespace will confuse the TypeScript compiler, and invalidate all previously declared classes in android. (Android SDK) resulting in TSC errors. Google's play-services libraries reside in the com.google.android.gms note the .android. and that is a showstopper for now.

For these reasons we are rolling out dts generation support behind a tns build/run android --androidTypings flag , in 2.4.0, with support for only the android SDK and all android support libraries

petekanev avatar Nov 07 '16 14:11 petekanev

@Pip3r4o Interesting. That might explain why I could never get full https://github.com/OneSignal/OneSignal-Android-SDK declarations since it required com.google.android.gms.

What's strange is that when I throw com.soundcloud.android.crop https://github.com/jdamcd/android-crop through the generator the declarations come out fine.

declare module com {
    export module soundcloud {
        export module android {
            export module crop {
                export class Crop extends java.lang.Object {
                    public static REQUEST_CROP: number;
                    public static REQUEST_PICK: number;
                    public static RESULT_ERROR: number;
                    public start(param0: android.content.Context, param1: android.support.v4.app.Fragment, param2: number): void;
                    public static pickImage(param0: android.app.Activity): void;
                    public start(param0: android.content.Context, param1: android.support.v4.app.Fragment): void;
                    public asSquare(): com.soundcloud.android.crop.Crop;
                    public static of(param0: android.net.Uri, param1: android.net.Uri): com.soundcloud.android.crop.Crop;
                    ...
                }
            }
        }
    }
}

roblav96 avatar Nov 07 '16 14:11 roblav96

@roblav96 declarations do come out fine-looking, executing tsc however will throw errors saying content not found on com.soundcloud.android when the typing should instead be referring to android.content.Context

petekanev avatar Nov 07 '16 15:11 petekanev

@Pip3r4o Yes that's certainly true.

roblav96 avatar Nov 09 '16 05:11 roblav96