Working on creating an android studio plugin using IntelliJ .
Following the guide https://plugins.jetbrains.com/docs/intellij/gradle-build-system.html using the Gradle
and the android studio plugin guide https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-pluginxml-file
After created the project using the wizard and added the section runIde.
I am getting an error.
Expression 'runIde' cannot be invoked as a function. The function 'invoke()' is not found.
here is the build.gradel.kts.
plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "1.6.20"
id("org.jetbrains.intellij") version "1.5.2"
}
group = "com.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
version.set("212.5712.43")
type.set("IC") // Target IDE Platform
plugins.set(listOf("android"))
}
runIde {
// Absolute path to installed target 3.5 Android Studio to use as
// IDE Development Instance (the "Contents" directory is macOS specific):
ideDir.set(file("/Applications/Android Studio.app/Contents"))
}
tasks {
// Set the JVM compatibility versions
withType<JavaCompile> {
sourceCompatibility = "11"
targetCompatibility = "11"
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
patchPluginXml {
sinceBuild.set("212")
untilBuild.set("222.*")
}
signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}
publishPlugin {
token.set(System.getenv("PUBLISH_TOKEN"))
}
}
OS.
macOS Monterey version 12.4.
The IntelliJ info.
IntelliJ IDEA 2022.1.1 (Community Edition).
Build #IC-221.5591.52, built on May 11, 2022.
Android Studio info.
Android Studio Chipmunk|2021.2.1.
Build#AI-212.5712.43.2112.8512546, Build on April 29, 2022.
Your runIde needs to be in the tasks block:
tasks {
runIde {
// Absolute path to installed target 3.5 Android Studio to use as
// IDE Development Instance (the "Contents" directory is macOS specific):
ideDir.set(file("/Applications/Android Studio.app/Contents"))
}
}
Related
I am trying to build a template of a Multiplatform library module in Android studio that can interoperate seamlessly with other normal Android library and application modules. I've found it's easy enough to make a Multiplatform Android project technically work in terms of compiling, running and publishing artefacts, but one problem I can't seem to solve is getting the source sets to show correctly in the Android project files pane view.
So you can see in the Project view here, the sources are divided into android, native and common directories and their respective test directories, for a total of six source directories:
In the Android Project view this is rendered by build targets instead of source file directories, so that this 'typing-sdk' module example has total of 10 different sub-modules. And you'll notice androidMain and androidTest are not among them: instead of being rendered as submodules, their sources fall under an inline kotlin directory instead; you can see the main and test com.demo.typing packages respectively.
It is a little annoying that every single build target gets its own submodule, when in practice, one will virtually never actually need to use some of these, like 'iosArm64Test' for example. Nevertheless, I can live with redundant submodules. The central problem here is that each of these submodules are populated with the wrong source files.
So whereas in the file structure, both the common and native sets have their own source files, as you can seen here:
In the Android Project View, every single submodule contains the Android sources!?
Either this is a bug in how Android Studio interoperates with the Kotlin Multiplatform Gradle Plugin, or there's something wrong with the Gradle build file I have written, which is this (using Gradle 7.1):
plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.6.10'
id 'com.android.library' version '7.0.4'
}
allprojects {
group = 'typing'
version = '1.0'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
google()
}
}
kotlin {
android()
ios()
sourceSets {
commonMain
commonTest
androidMain {
dependsOn(commonMain)
}
androidAndroidTestRelease
androidTest {
dependsOn(commonTest)
dependsOn(androidAndroidTestRelease)
}
nativeMain {
dependsOn(commonMain)
}
nativeTest {
dependsOn(commonTest)
}
iosMain {
dependsOn(nativeMain)
iosX64Main.dependsOn(it)
iosArm64Main.dependsOn(it)
}
iosTest {
dependsOn(nativeTest)
iosX64Test.dependsOn(it)
iosArm64Test.dependsOn(it)
}
}
}
android {
compileSdk 31
defaultConfig {
minSdk 23
targetSdk 30
}
}
I have noticed most of the source examples already out there are using Kotlin DSL, which is preferable, but circumstances are forcing me to use Groovy here. On another project I have that is Kotlin DSL, using earlier versions of the Gradle (7.0.2) Android Gradle Plugin (7.0.2) and Kotlin (1.5.20), the Android project view is rendered differently, and though still quite defective, it's not so disastrously wrong as to have Android sources listed under every single build target module. In the Android block on that project you have a second definition of the sourcesets to the com.android.library plugin:
android {
compileSdk = 31
defaultConfig {
minSdk = 23
targetSdk = 30
consumerProguardFiles("proguard-rules.pro")
}
sourceSets.all {
java.srcDirs(file("src/android${name.capitalize()}/kotlin"))
res.srcDirs(file("src/android${name.capitalize()}/res"))
resources.srcDirs(file("src/android${name.capitalize()}/resources"))
manifest.srcFile(file("src/android${name.capitalize()}/AndroidManifest.xml"))
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
I don't know how to directly translate this into Groovy, but following the Android documentation, one can put something like this:
android {
compileSdk 31
defaultConfig {
minSdk 23
targetSdk 30
}
sourceSets {
main {
java.srcDirs = ['src/androidMain/kotlin']
manifest.srcFile 'src/androidMain/AndroidManifest.xml'
}
test {
java.srcDirs = ['src/androidTest/kotlin']
}
androidTest {
setRoot 'src/androidTest/kotlin'
}
}
}
Unfortunately this doesn't solve the problem. If nobody can show me workable Gradle scripts that don't create hideous and broken source file views in Android Studio, I will submit this as a bug to JetBrains.
IntellIJ is the recommended IDE to use when it comes to Multiplatform development.
Android Studio is for more Android Specific things, I don't think Android project view is something JetBrains wants to support, maybe there will be a Kotlin Multiplatform Project View at some point, but not at the moment.
(If you open a Spring, NodeJS, iOS or any other type of project the Android Project View will similarly seem broken)
I'm building apk from an android project exported from Cocos Creator V2.4.3 but getting the below error with Gradle
A problem occurred configuring project ':game'.
> java.lang.NullPointerException (no error message)
I've deleted all android SDK, NDK and re-installed Android Studio, then re-update SDK, NDK, Build Tool.
But the error still occurs.
Some configurations:
Android SDK = 23, 26, 28, 30
SDK Build Tool = 30.0.3
NDK = 19.2.5345600
Gradle version: 4.10.3
Gradle plugin version: 3.2.0
JDK: jdk1.8.0_281
The build.gradle looks like this
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Anyone has any idea about what should be done to fix this?
I had the same issue, I solved this by specifying 3.6.3 as Android Gradle plugin version and 5.6.4 as Gradle version.
You can do this by clicking File--> project structure--> project then type the versions I mentioned above then click on apply.
wait for the new versions to be downloaded and rebuild your project.
The problem was with setting the NDK Path in Cocos Creator.
I've changed
C:\Users\SomeUserName\AppData\Local\Android\Sdk\ndk
into
C:\Users\SomeUserName\AppData\Local\Android\Sdk\ndk\19.2.5345600
And things worked
AndroidStudio version: 4.1
Device: MacBook Pro MacOs 10.15.7
Step1: new a example project
Step2: new a module named mylibrary
Step3: create 'api' dir at mylibrary/src/main
Step4: modify build.gradle in app as followed
android {
...
sourceSets{
main{
java.srcDirs "${rootDir}/mylibrary/src/main/api"
}
}
}
mylibrary cannot recognize java file!
I had loads of issues with the new android 4.1 update I then updated the version to Android Studio 4.1 RC 2 https://developer.android.com/studio/archive the link to the download is there give it a try if it don't work just go back to 4.0
I downloaded the android studio 2.4 preview 6. It has support for java 8 without using jack. This is my application gradle filebuildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.4.0-alpha6'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task wrapper(type: Wrapper) {
description 'Creates the gradle wrapper.'
gradleVersion '2.8'
}
And this is my gradle-wrapper.properties file
#Thu Apr 13 15:20:48 IST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip
But I keep getting the error :
Error:Unable to find method 'org.gradle.tooling.model.gradle.GradleBuild.getIncludedBuilds()Lorg/gradle/tooling/model/DomainObjectSet;'
What could be leading to the error and how can I solve it? I have tried invalidate cache/restart.
Everything looks fine to me. If you're going to use a beta build you shouldn't rely much on it for reasons like this; it's too buggy. Downgrade to the older version if you're going to push something to production or sell it, and if you're just looking at the new features, change to an older/newer preview. Android studio isn't known for being built that well.
Agree with Alex, I had mostly all the same versions as you:
Dependencies: Grade 2.4.0-alpha6
Gradle Wrapper: gradle-3.4.1-all.zip
Android Studio 2.4 preview 7
Had exactly the same error after updating from Android Studio 2.4 preview 1.
I got off the Canary channel and downloaded stable version 2.3.1 - Problem solved.
I might try a preview again in a couple months but I've found the last couple to be super buggy.
I am on Android Studio 1.3 which I believe requires gradle version 1.2 and up. Some of my team can't update yet and so need to use a lower gradle version. Is there an easy way to do that in the same build script? Something like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
if (Android Studio Version <= 1.2 )
{
classpath 'com.android.tools.build:gradle:1.1.0'
}
else
{
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
}