TimmyRB / snapkit

SnapKit is a Flutter plugin that allows you to integrate Snapchat's own SDKs into your Flutter projects!
https://pub.dev/packages/snapkit
MIT License
30 stars 16 forks source link

Error when compiling app on Android #22

Closed Tom3652 closed 3 years ago

Tom3652 commented 3 years ago

Thanks @TimmyRB for the plugin ! Actually i wanted to try it and unfortunately i can't build :/

Steps to Reproduce

  1. Build a new project with snapkit: 1.2.2
  2. See the error below

Expected results:

The application should compile.

Actual results:

The application can't compile and can't run on Android.

Logs Error log : ``` /Users/tom3652/StudioProjects/testproject/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:184: error: cannot access LoginStateController flutterEngine.getPlugins().add(new com.jacobbrasil.snapkit.SnapkitPlugin()); ^ class file for com.snapchat.kit.sdk.core.controller.LoginStateController not found 1 error FAILURE: Build failed with an exception. ``` Flutter doctor output : ``` [✓] Flutter (Channel stable, 2.5.0, on macOS 11.6 20G165 darwin-x64, locale fr-FR) • Flutter version 2.5.0 at /Users/foxtom/Desktop/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 4cc385b4b8 (9 days ago), 2021-09-07 23:01:49 -0700 • Engine revision f0826da7ef • Dart version 2.14.0 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/foxtom/Library/Android/sdk • Platform android-30, build-tools 30.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.5.1, Build version 12E507 • CocoaPods version 1.11.0 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2020.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165) [✓] VS Code (version 1.60.1) • VS Code at /Users/foxtom/Desktop/Visual Studio Code.app/Contents • Flutter extension version 3.26.0 [✓] Connected device (3 available) • CPH1931 (mobile) • ee9b32b5 • android-arm64 • Android 10 (API 29) • macOS (desktop) • macos • darwin-x64 • macOS 11.6 20G165 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.82 • No issues found! ```
nicklbaert commented 3 years ago

Same thing here...

TimmyRB commented 3 years ago

Sorry for the delay @Tom3652 @nicklbaert , I've been quite busy as of late. Could you please provide your android/build.gradle as well as your android/app/build.gradle! This issue usually occurs when Snapchat's Native SDK isn't properly imported into your projects.

nicklbaert commented 3 years ago

Hi, thanks for replying and helping me out :)

This is my app/build.gradle:

def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } }

def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") }

def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' }

def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' }

apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) }

repositories { google() }

android { compileSdkVersion 30

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    applicationId "com.pyro.app"
    minSdkVersion 21
    targetSdkVersion 30
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    multiDexEnabled true
}
signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
        storePassword keystoreProperties['storePassword']
    }
}

buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}

}

flutter { source '../..' }

dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.google.firebase:firebase-analytics:17.2.2' implementation 'com.android.support:multidex:1.0.3' implementation "com.google.code.gson:gson:2.8.5" }


This is the android/build.gradle:

buildscript { ext.kotlin_version = '1.3.50' repositories { google() jcenter() }

dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.3'
    classpath 'com.android.tools.build:gradle:3.6.0'

}

}

allprojects { repositories { google() jcenter() } }

rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') }

task clean(type: Delete) { delete rootProject.buildDir }

dependencies { }

Tom3652 commented 3 years ago

Hello ! I have realized i had not followed your wiki with the snapchat config in the build.gradle :) so i will do everything and check !

TimmyRB commented 3 years ago

@nicklbaert looks like you're not importing the dependancies at all, made sure to follow the Android Installation Instructions on the Wiki