1

I'm trying to create my own custom library for Android to streamline the developing process of FTC Robots, I've tried creating a project in IntelliJ and use MavenCentral to publish it, tried publishing it to MavenLocal and even to a GitHub page and all returns the same error. As a troubleshooting step I decided to create the library as a module inside the RobotController Android Studio project, and got the same error.

The error seems to be related to a gradle process or task "ExtDexDebugAndroidTest" and the jar generated by my publish.gradle. The error reads: "java.lang.NullPointerException".

Here is my build.gradle:

plugins { id 'com.android.library' } android { namespace 'org.overture.ftc.overftclib' compileSdk 34 defaultConfig { minSdkVersion 16 aarMetadata{ minCompileSdk = 29 } testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'com.google.android.material:material:1.10.0' implementation project(':FtcRobotController') testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } 

And here is my publish.gradle:

apply plugin: 'maven-publish' ext.licenseFile = files("$rootDir/LICENSE.txt") def pubVersion = '0.0.1' def outputsFolder = file("$buildDir/outputs") def versionFile = file("$outputsFolder/version.txt") task outputVersions() { description = 'Prints the version of the library to a file' group = 'Build' outputs.files(versionFile) doFirst { buildDir.mkdir() outputsFolder.mkdir() } doLast { versionFile.write pubVersion } } task libraryBuild() {} build.dependsOn outputVersions task copyAllOutputs(type: Copy) { destinationDir file("$buildDir/allOutputs") from versionFile dependsOn outputVersions } build.dependsOn copyAllOutputs copyAllOutputs.dependsOn outputVersions ext.addTaskToCopyAllOutputs = { task -> copyAllOutputs.dependsOn task copyAllOutputs.inputs.file task.archiveFile copyAllOutputs.from task.archiveFile } def artifactGroupId = 'com.overture.ftc.lib' def baseArtifactId = 'OvertureFTCLib' // Tasks for creating additional artifacts, like sources and Javadoc task androidSourcesJar(type: Jar) { classifier = 'sources' from android.sourceSets.main.java.srcDirs } task androidJavadocs(type: Javadoc) { source = android.sourceSets.main.java.srcDirs classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) } task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { classifier = 'javadoc' from androidJavadocs.destinationDir } build.dependsOn androidSourcesJar build.dependsOn androidJavadocsJar addTaskToCopyAllOutputs(androidSourcesJar) addTaskToCopyAllOutputs(androidJavadocsJar) libraryBuild.dependsOn build def releasesRepoUrl = "$buildDir/repos/releases" publishing { publications { androidLibrary(MavenPublication) { groupId = artifactGroupId artifactId = baseArtifactId version = pubVersion afterEvaluate { from components.release } artifact androidSourcesJar artifact androidJavadocsJar } } repositories { maven { url = releasesRepoUrl } } } task cleanReleaseRepo(type: Delete) { delete releasesRepoUrl } tasks.matching { it != cleanReleaseRepo }.all { it.dependsOn cleanReleaseRepo } 

Here are screenshots of the output: ExtDexDebugAndroidTest java.lang.NullPointerException

Hello, I'm trying to create my own custom library for Android to streamline the developing process of FTC Robots, I've tried creating a project in IntelliJ and use MavenCentral to publish it, tried publishing it to MavenLocal and even to a GitHub page and all returns the same error. As a troubleshooting step I decided to create the library as a module inside the RobotController Android Studio project, and got the same error.

The error seems to be related to a gradle process or task "ExtDexDebugAndroidTest" and the jar generated by my publish.gradle. The error reads: "java.lang.NullPointerException".

Errors: DebugExtDexDebugAndroidTest:

> Task :overftclib:mergeExtDexDebugAndroidTest AGPBI: {"kind":"error","text":"java.lang.NullPointerException: Cannot invoke \"String.length()\" because \"<parameter1>\" is null","sources":[{"file":"C:\\Users\\santy\\.gradle\\caches\\transforms-3\\9d823f17cc7bfaba9537b6c404b8a19f\\transformed\\appcompat-resources-1.7.0-runtime.jar"}],"tool":"D8"} AGPBI: {"kind":"error","text":"java.lang.NullPointerException: Cannot invoke \"String.length()\" because \"<parameter1>\" is null","sources":[{"file":"C:\\Users\\santy\\.gradle\\caches\\transforms-3\\6303bfbaba1977f71e281e2c3baabe3f\\transformed\\appcompat-1.7.0-runtime.jar"}],"tool":"D8"} AGPBI: {"kind":"error","text":"java.lang.NullPointerException","sources":[{"file":"C:\\Users\\santy\\.gradle\\caches\\transforms-3\\6303bfbaba1977f71e281e2c3baabe3f\\transformed\\appcompat-1.7.0-runtime.jar"}],"tool":"D8"} > Task :overftclib:mergeExtDexDebugAndroidTest FAILED 

java.lang.NullPointerException:

java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null 
2
  • Please add error information to questions as text and not as images. Commented Aug 22, 2024 at 8:17
  • Thank you for the follow-up. I edited the original question. Commented Aug 22, 2024 at 22:27

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.