kandi background
Explore Kits

javapoet | A Java API for generating .java source files. | REST library

 by   square Java Version: Current License: Apache-2.0

 by   square Java Version: Current License: Apache-2.0

Download this library from

kandi X-RAY | javapoet Summary

javapoet is a Java library typically used in Web Services, REST, Gradle applications. javapoet has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can download it from GitHub.
JavaPoet is a Java API for generating .java source files. Source file generation can be useful when doing things such as annotation processing or interacting with metadata files (e.g., database schemas, protocol formats). By generating code, you eliminate the need to write boilerplate while also keeping a single source of truth for the metadata.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • javapoet has a highly active ecosystem.
  • It has 8940 star(s) with 1155 fork(s). There are 355 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 72 open issues and 300 have been closed. On average issues are closed in 158 days. There are 31 open pull requests and 0 closed requests.
  • It has a positive sentiment in the developer community.
  • The latest version of javapoet is current.
javapoet Support
Best in #REST
Average in #REST
javapoet Support
Best in #REST
Average in #REST

quality kandi Quality

  • javapoet has 0 bugs and 0 code smells.
javapoet Quality
Best in #REST
Average in #REST
javapoet Quality
Best in #REST
Average in #REST

securitySecurity

  • javapoet has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • javapoet code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
javapoet Security
Best in #REST
Average in #REST
javapoet Security
Best in #REST
Average in #REST

license License

  • javapoet is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
javapoet License
Best in #REST
Average in #REST
javapoet License
Best in #REST
Average in #REST

buildReuse

  • javapoet releases are not available. You will need to build from source code and install.
  • Build file is available. You can build the component from source.
  • Installation instructions, examples and code snippets are available.
  • javapoet saves you 4645 person hours of effort in developing the same functionality from scratch.
  • It has 9897 lines of code, 847 functions and 41 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
javapoet Reuse
Best in #REST
Average in #REST
javapoet Reuse
Best in #REST
Average in #REST
Top functions reviewed by kandi - BETA

kandi has reviewed javapoet and discovered the below as its top functions. This is intended to give you an instant insight into javapoet implemented functionality, and help decide if they suit your requirements.

  • Returns the fully qualified name for the given class .
  • Escapes a string literal with double quotes .
  • Appends a string to the output buffer .
  • Returns a builder that overrides the given method .
  • Emit annotation values .
  • Returns the best guess for the class name .
  • Returns a new name for the given suggestion .
  • Converts this object to a JavaFileObject .
  • Get the type variable for a given type variable .
  • Converts this class to a builder .

javapoet Key Features

A Java API for generating .java source files.

Example

copy iconCopydownload iconDownload
package com.example.helloworld;

public final class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello, JavaPoet!");
  }
}

Code & Control Flow

copy iconCopydownload iconDownload
MethodSpec main = MethodSpec.methodBuilder("main")
    .addCode(""
        + "int total = 0;\n"
        + "for (int i = 0; i < 10; i++) {\n"
        + "  total += i;\n"
        + "}\n")
    .build();

$L for Literals

copy iconCopydownload iconDownload
private MethodSpec computeRange(String name, int from, int to, String op) {
  return MethodSpec.methodBuilder(name)
      .returns(int.class)
      .addStatement("int result = 0")
      .beginControlFlow("for (int i = $L; i < $L; i++)", from, to)
      .addStatement("result = result $L i", op)
      .endControlFlow()
      .addStatement("return result")
      .build();
}

$S for Strings

copy iconCopydownload iconDownload
public static void main(String[] args) throws Exception {
  TypeSpec helloWorld = TypeSpec.classBuilder("HelloWorld")
      .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
      .addMethod(whatsMyName("slimShady"))
      .addMethod(whatsMyName("eminem"))
      .addMethod(whatsMyName("marshallMathers"))
      .build();

  JavaFile javaFile = JavaFile.builder("com.example.helloworld", helloWorld)
      .build();

  javaFile.writeTo(System.out);
}

private static MethodSpec whatsMyName(String name) {
  return MethodSpec.methodBuilder(name)
      .returns(String.class)
      .addStatement("return $S", name)
      .build();
}

$T for Types

copy iconCopydownload iconDownload
MethodSpec today = MethodSpec.methodBuilder("today")
    .returns(Date.class)
    .addStatement("return new $T()", Date.class)
    .build();

TypeSpec helloWorld = TypeSpec.classBuilder("HelloWorld")
    .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
    .addMethod(today)
    .build();

JavaFile javaFile = JavaFile.builder("com.example.helloworld", helloWorld)
    .build();

javaFile.writeTo(System.out);

$N for Names

copy iconCopydownload iconDownload
public String byteToHex(int b) {
  char[] result = new char[2];
  result[0] = hexDigit((b >>> 4) & 0xf);
  result[1] = hexDigit(b & 0xf);
  return new String(result);
}

public char hexDigit(int i) {
  return (char) (i < 10 ? i + '0' : i - 10 + 'a');
}

Code block format strings

copy iconCopydownload iconDownload
CodeBlock.builder().add("I ate $L $L", 3, "tacos")

Methods

copy iconCopydownload iconDownload
MethodSpec flux = MethodSpec.methodBuilder("flux")
    .addModifiers(Modifier.ABSTRACT, Modifier.PROTECTED)
    .build();

TypeSpec helloWorld = TypeSpec.classBuilder("HelloWorld")
    .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT)
    .addMethod(flux)
    .build();

Constructors

copy iconCopydownload iconDownload
MethodSpec flux = MethodSpec.constructorBuilder()
    .addModifiers(Modifier.PUBLIC)
    .addParameter(String.class, "greeting")
    .addStatement("this.$N = $N", "greeting", "greeting")
    .build();

TypeSpec helloWorld = TypeSpec.classBuilder("HelloWorld")
    .addModifiers(Modifier.PUBLIC)
    .addField(String.class, "greeting", Modifier.PRIVATE, Modifier.FINAL)
    .addMethod(flux)
    .build();

Parameters

copy iconCopydownload iconDownload
ParameterSpec android = ParameterSpec.builder(String.class, "android")
    .addModifiers(Modifier.FINAL)
    .build();

MethodSpec welcomeOverlords = MethodSpec.methodBuilder("welcomeOverlords")
    .addParameter(android)
    .addParameter(String.class, "robot", Modifier.FINAL)
    .build();

Fields

copy iconCopydownload iconDownload
FieldSpec android = FieldSpec.builder(String.class, "android")
    .addModifiers(Modifier.PRIVATE, Modifier.FINAL)
    .build();

TypeSpec helloWorld = TypeSpec.classBuilder("HelloWorld")
    .addModifiers(Modifier.PUBLIC)
    .addField(android)
    .addField(String.class, "robot", Modifier.PRIVATE, Modifier.FINAL)
    .build();

Interfaces

copy iconCopydownload iconDownload
TypeSpec helloWorld = TypeSpec.interfaceBuilder("HelloWorld")
    .addModifiers(Modifier.PUBLIC)
    .addField(FieldSpec.builder(String.class, "ONLY_THING_THAT_IS_CONSTANT")
        .addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
        .initializer("$S", "change")
        .build())
    .addMethod(MethodSpec.methodBuilder("beep")
        .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT)
        .build())
    .build();

Enums

copy iconCopydownload iconDownload
TypeSpec helloWorld = TypeSpec.enumBuilder("Roshambo")
    .addModifiers(Modifier.PUBLIC)
    .addEnumConstant("ROCK")
    .addEnumConstant("SCISSORS")
    .addEnumConstant("PAPER")
    .build();

Anonymous Inner Classes

copy iconCopydownload iconDownload
TypeSpec comparator = TypeSpec.anonymousClassBuilder("")
    .addSuperinterface(ParameterizedTypeName.get(Comparator.class, String.class))
    .addMethod(MethodSpec.methodBuilder("compare")
        .addAnnotation(Override.class)
        .addModifiers(Modifier.PUBLIC)
        .addParameter(String.class, "a")
        .addParameter(String.class, "b")
        .returns(int.class)
        .addStatement("return $N.length() - $N.length()", "a", "b")
        .build())
    .build();

TypeSpec helloWorld = TypeSpec.classBuilder("HelloWorld")
    .addMethod(MethodSpec.methodBuilder("sortByLength")
        .addParameter(ParameterizedTypeName.get(List.class, String.class), "strings")
        .addStatement("$T.sort($N, $L)", Collections.class, "strings", comparator)
        .build())
    .build();

Annotations

copy iconCopydownload iconDownload
MethodSpec toString = MethodSpec.methodBuilder("toString")
    .addAnnotation(Override.class)
    .returns(String.class)
    .addModifiers(Modifier.PUBLIC)
    .addStatement("return $S", "Hoverboard")
    .build();

Javadoc

copy iconCopydownload iconDownload
MethodSpec dismiss = MethodSpec.methodBuilder("dismiss")
    .addJavadoc("Hides {@code message} from the caller's history. Other\n"
        + "participants in the conversation will continue to see the\n"
        + "message in their own history unless they also delete it.\n")
    .addJavadoc("\n")
    .addJavadoc("<p>Use {@link #delete($T)} to delete the entire\n"
        + "conversation for all participants.\n", Conversation.class)
    .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT)
    .addParameter(Message.class, "message")
    .build();

Download

copy iconCopydownload iconDownload
<dependency>
  <groupId>com.squareup</groupId>
  <artifactId>javapoet</artifactId>
  <version>1.13.0</version>
</dependency>

License

copy iconCopydownload iconDownload
Copyright 2015 Square, Inc.

JavaWriter

copy iconCopydownload iconDownload
[dl]: https://search.maven.org/remote_content?g=com.squareup&a=javapoet&v=LATEST
[snap]: https://oss.sonatype.org/content/repositories/snapshots/com/squareup/javapoet/
[javadoc]: https://square.github.io/javapoet/1.x/javapoet/
[javawriter]: https://github.com/square/javapoet/tree/javawriter_2
[javawriter_maven]: https://search.maven.org/#artifactdetails%7Ccom.squareup%7Cjavawriter%7C2.5.1%7Cjar
[formatter]: https://developer.android.com/reference/java/util/Formatter.html
[modifier]: https://docs.oracle.com/javase/8/docs/api/javax/lang/model/element/Modifier.html

Could not resolve com.google.guava:guava:30.1-jre - Gradle project sync failed. Basic functionality will not work properly - in kotlin project

copy iconCopydownload iconDownload
    repositories {
        mavenCentral()
        google()
    }

-----------------------
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenCentral()
        google()
    }
}

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

How to add Walkmod plugin to eclipse?

copy iconCopydownload iconDownload
<plugin>
  <groupId>org.walkmod.maven.plugins</groupId>
  <artifactId>walkmod-maven-plugin</artifactId>
  <version>2.0.1</version>
  <executions>
    <execution>
      <goals>
        <goal>apply</goal>
      </goals>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>org.apache.ivy</groupId>
      <artifactId>ivy</artifactId>
      <version>2.5.0</version>
    </dependency>
  </dependencies>
</plugin>

How to generate annotations and use lombok with javapoet?

copy iconCopydownload iconDownload
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.20</version>
    <scope>provided</scope>
</dependency>

running flutter project for first time

copy iconCopydownload iconDownload
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip // here mine is 5.6.2

How to get type and generic type from javax.lang.model.VariableElement?

copy iconCopydownload iconDownload
        VariableElement fieldElement;

        Symbol.TypeSymbol containerForEnclosingElement=((Type)fieldElement.asType()).tsym;
        Element enclosingElement=fieldElement.getEnclosingElement();

        System.out.println("containerForEnclosingElement:- " +  containerForEnclosingElement);
        System.out.println("enclosingElement:- " +  enclosingElement);
        System.out.println("enclosingElement Name:- " +  enclosingElement.getSimpleName());
        System.out.println("fieldElement without root Type:- "+((Type) fieldElement.asType()).getTypeArguments().get(0));
containerForEnclosingElement:- java.util.Set
enclosingElement:- com.example.demo.test.model.User.
enclosingElement Name:- User
fieldElement without root Type:- com.example.demo.test.model.User
-----------------------
        VariableElement fieldElement;

        Symbol.TypeSymbol containerForEnclosingElement=((Type)fieldElement.asType()).tsym;
        Element enclosingElement=fieldElement.getEnclosingElement();

        System.out.println("containerForEnclosingElement:- " +  containerForEnclosingElement);
        System.out.println("enclosingElement:- " +  enclosingElement);
        System.out.println("enclosingElement Name:- " +  enclosingElement.getSimpleName());
        System.out.println("fieldElement without root Type:- "+((Type) fieldElement.asType()).getTypeArguments().get(0));
containerForEnclosingElement:- java.util.Set
enclosingElement:- com.example.demo.test.model.User.
enclosingElement Name:- User
fieldElement without root Type:- com.example.demo.test.model.User

Android studio shows very specific incorrect errors with JavaPoet library

copy iconCopydownload iconDownload
annotationProcessor files('../migrationprocessor/build/libs/migrationprocessor.jar')
annotationProcessor project(':migrationprocessor')
-----------------------
annotationProcessor files('../migrationprocessor/build/libs/migrationprocessor.jar')
annotationProcessor project(':migrationprocessor')

Implementing generated interface with JavaPoet

copy iconCopydownload iconDownload
TypeSpec.Builder    addSuperinterface(Type superinterface) 
TypeSpec.Builder    addSuperinterface(TypeName superinterface)
public static ClassName get(String packageName, String simpleName, String... simpleNames)
@Data
public class SimpleClassSpecs {

    public final TypeSpec interfaceSpec;
    public final TypeSpec classSpec;

    public SimpleClassSpecs() {
        interfaceSpec = TypeSpec.interfaceBuilder("MyInterface")
                .build();

        TypeName interfaceTypeName = ClassName.get("", interfaceSpec.name);
        classSpec = TypeSpec.classBuilder("MyClass")
                .addSuperinterface(interfaceTypeName)
                .build();
    }
}
@Test
public void should_generate_spec_with_superInterface() {
   SimpleClassSpecs ps = new SimpleClassSpecs();
   assertThat(ps.classSpec.toString()).contains("class MyClass implements MyInterface");
}
class MyClass implements MyInterface {
}
-----------------------
TypeSpec.Builder    addSuperinterface(Type superinterface) 
TypeSpec.Builder    addSuperinterface(TypeName superinterface)
public static ClassName get(String packageName, String simpleName, String... simpleNames)
@Data
public class SimpleClassSpecs {

    public final TypeSpec interfaceSpec;
    public final TypeSpec classSpec;

    public SimpleClassSpecs() {
        interfaceSpec = TypeSpec.interfaceBuilder("MyInterface")
                .build();

        TypeName interfaceTypeName = ClassName.get("", interfaceSpec.name);
        classSpec = TypeSpec.classBuilder("MyClass")
                .addSuperinterface(interfaceTypeName)
                .build();
    }
}
@Test
public void should_generate_spec_with_superInterface() {
   SimpleClassSpecs ps = new SimpleClassSpecs();
   assertThat(ps.classSpec.toString()).contains("class MyClass implements MyInterface");
}
class MyClass implements MyInterface {
}
-----------------------
TypeSpec.Builder    addSuperinterface(Type superinterface) 
TypeSpec.Builder    addSuperinterface(TypeName superinterface)
public static ClassName get(String packageName, String simpleName, String... simpleNames)
@Data
public class SimpleClassSpecs {

    public final TypeSpec interfaceSpec;
    public final TypeSpec classSpec;

    public SimpleClassSpecs() {
        interfaceSpec = TypeSpec.interfaceBuilder("MyInterface")
                .build();

        TypeName interfaceTypeName = ClassName.get("", interfaceSpec.name);
        classSpec = TypeSpec.classBuilder("MyClass")
                .addSuperinterface(interfaceTypeName)
                .build();
    }
}
@Test
public void should_generate_spec_with_superInterface() {
   SimpleClassSpecs ps = new SimpleClassSpecs();
   assertThat(ps.classSpec.toString()).contains("class MyClass implements MyInterface");
}
class MyClass implements MyInterface {
}
-----------------------
TypeSpec.Builder    addSuperinterface(Type superinterface) 
TypeSpec.Builder    addSuperinterface(TypeName superinterface)
public static ClassName get(String packageName, String simpleName, String... simpleNames)
@Data
public class SimpleClassSpecs {

    public final TypeSpec interfaceSpec;
    public final TypeSpec classSpec;

    public SimpleClassSpecs() {
        interfaceSpec = TypeSpec.interfaceBuilder("MyInterface")
                .build();

        TypeName interfaceTypeName = ClassName.get("", interfaceSpec.name);
        classSpec = TypeSpec.classBuilder("MyClass")
                .addSuperinterface(interfaceTypeName)
                .build();
    }
}
@Test
public void should_generate_spec_with_superInterface() {
   SimpleClassSpecs ps = new SimpleClassSpecs();
   assertThat(ps.classSpec.toString()).contains("class MyClass implements MyInterface");
}
class MyClass implements MyInterface {
}
-----------------------
TypeSpec.Builder    addSuperinterface(Type superinterface) 
TypeSpec.Builder    addSuperinterface(TypeName superinterface)
public static ClassName get(String packageName, String simpleName, String... simpleNames)
@Data
public class SimpleClassSpecs {

    public final TypeSpec interfaceSpec;
    public final TypeSpec classSpec;

    public SimpleClassSpecs() {
        interfaceSpec = TypeSpec.interfaceBuilder("MyInterface")
                .build();

        TypeName interfaceTypeName = ClassName.get("", interfaceSpec.name);
        classSpec = TypeSpec.classBuilder("MyClass")
                .addSuperinterface(interfaceTypeName)
                .build();
    }
}
@Test
public void should_generate_spec_with_superInterface() {
   SimpleClassSpecs ps = new SimpleClassSpecs();
   assertThat(ps.classSpec.toString()).contains("class MyClass implements MyInterface");
}
class MyClass implements MyInterface {
}

Community Discussions

Trending Discussions on javapoet
  • Could not resolve com.google.guava:guava:30.1-jre - Gradle project sync failed. Basic functionality will not work properly - in kotlin project
  • Error while fetching data from cassandra using pyspark
  • How to add Walkmod plugin to eclipse?
  • How to generate annotations and use lombok with javapoet?
  • Android build warning Mapping new ns to old ns
  • running flutter project for first time
  • How to get type and generic type from javax.lang.model.VariableElement?
  • Android studio shows very specific incorrect errors with JavaPoet library
  • Implementing generated interface with JavaPoet
  • Android data binding problem: "Cause: couldn't make a guess for"
Trending Discussions on javapoet

QUESTION

Could not resolve com.google.guava:guava:30.1-jre - Gradle project sync failed. Basic functionality will not work properly - in kotlin project

Asked 2022-Feb-14 at 19:47

It was a project that used to work well in the past, but after updating, the following errors appear.

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.retrofit_test"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

//    implementation 'com.google.guava:guava:30.1.1-jre'
    implementation 'com.google.guava:guava:30.1-jre'

//    implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.5.30-M1'

    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'

    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.google.code.gson:gson:2.8.7'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'

    implementation 'com.github.bumptech.glide:glide:4.12.0'
    implementation 'android.arch.persistence.room:guava:1.1.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

If we need more source code to check, I will update it.

The error contents are as follows.

A problem occurred configuring root project 'Retrofit_Test'.

   Could not resolve all artifacts for configuration ':classpath'.
   Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.30/kotlin-gradle-plugin-1.5.30.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :
   Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.32.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.4.32/kotlin-stdlib-jdk8-1.4.32.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:repository:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:aaptcompiler:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.analytics-library:shared:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.lint:lint-model:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > androidx.databinding:databinding-compiler-common:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.utp:android-test-plugin-host-retention-proto:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder-model:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:gradle-api:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2 > com.android.tools:common:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2 > com.android.tools.analytics-library:tracker:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2 > com.android.tools.build:manifest-merger:30.0.2
   Could not find org.apache.httpcomponents:httpmime:4.5.6.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/apache/httpcomponents/httpmime/4.5.6/httpmime-4.5.6.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdklib:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.analytics-library:crash:30.0.2
   Could not find commons-io:commons-io:2.4.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/commons-io/commons-io/2.4/commons-io-2.4.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > androidx.databinding:databinding-compiler-common:7.0.2
   Could not find org.ow2.asm:asm:7.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/ow2/asm/asm/7.0/asm-7.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:gradle-api:7.0.2
   Could not find org.ow2.asm:asm-analysis:7.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-analysis/7.0/asm-analysis-7.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
   Could not find org.ow2.asm:asm-commons:7.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-commons/7.0/asm-commons-7.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2
   Could not find org.ow2.asm:asm-util:7.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-util/7.0/asm-util-7.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2
   Could not find org.bouncycastle:bcpkix-jdk15on:1.56.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/bouncycastle/bcpkix-jdk15on/1.56/bcpkix-jdk15on-1.56.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2 > com.android.tools.build:apkzlib:7.0.2
   Could not find org.glassfish.jaxb:jaxb-runtime:2.3.2.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/glassfish/jaxb/jaxb-runtime/2.3.2/jaxb-runtime-2.3.2.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdklib:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:repository:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > androidx.databinding:databinding-compiler-common:7.0.2
   Could not find net.sf.jopt-simple:jopt-simple:4.9.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/net/sf/jopt-simple/jopt-simple/4.9/jopt-simple-4.9.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2
   Could not find com.squareup:javapoet:1.10.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/squareup/javapoet/1.10.0/javapoet-1.10.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > androidx.databinding:databinding-compiler-common:7.0.2
   Could not find com.google.protobuf:protobuf-java:3.10.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/google/protobuf/protobuf-java/3.10.0/protobuf-java-3.10.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.ddms:ddmlib:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:aapt2-proto:7.0.2-7396180
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:aaptcompiler:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.utp:android-device-provider-gradle-proto:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.utp:android-test-plugin-host-retention-proto:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.utp:android-test-plugin-result-listener-gradle-proto:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:bundletool:1.6.0
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.analytics-library:shared:30.0.2 > com.android.tools.analytics-library:protos:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2 > com.android.tools.analytics-library:tracker:30.0.2
   Could not find com.google.protobuf:protobuf-java-util:3.10.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/google/protobuf/protobuf-java-util/3.10.0/protobuf-java-util-3.10.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:bundletool:1.6.0
   Could not find com.google.code.gson:gson:2.8.6.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/google/code/gson/gson/2.8.6/gson-2.8.6.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdklib:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.analytics-library:shared:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > androidx.databinding:databinding-compiler-common:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.utp:android-test-plugin-result-listener-gradle-proto:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2 > com.android.tools.build:manifest-merger:30.0.2
   Could not find io.grpc:grpc-core:1.21.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/io/grpc/grpc-core/1.21.1/grpc-core-1.21.1.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.utp:android-test-plugin-result-listener-gradle-proto:30.0.2
   Could not find io.grpc:grpc-netty:1.21.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/io/grpc/grpc-netty/1.21.1/grpc-netty-1.21.1.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.utp:android-test-plugin-result-listener-gradle-proto:30.0.2
   Could not find io.grpc:grpc-protobuf:1.21.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/io/grpc/grpc-protobuf/1.21.1/grpc-protobuf-1.21.1.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.utp:android-test-plugin-result-listener-gradle-proto:30.0.2
   Could not find io.grpc:grpc-stub:1.21.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/io/grpc/grpc-stub/1.21.1/grpc-stub-1.21.1.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.utp:android-test-plugin-result-listener-gradle-proto:30.0.2
   Could not find com.google.crypto.tink:tink:1.3.0-rc2.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/google/crypto/tink/tink/1.3.0-rc2/tink-1.3.0-rc2.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
   Could not find com.google.flatbuffers:flatbuffers-java:1.12.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/google/flatbuffers/flatbuffers-java/1.12.0/flatbuffers-java-1.12.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
   Could not find org.tensorflow:tensorflow-lite-metadata:0.1.0-rc2.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/tensorflow/tensorflow-lite-metadata/0.1.0-rc2/tensorflow-lite-metadata-0.1.0-rc2.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2
   Could not find org.bouncycastle:bcprov-jdk15on:1.56.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/bouncycastle/bcprov-jdk15on/1.56/bcprov-jdk15on-1.56.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2 > com.android.tools.build:apkzlib:7.0.2
   Could not find com.google.guava:guava:30.1-jre.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/google/guava/guava/30.1-jre/guava-30.1-jre.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:aaptcompiler:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.analytics-library:crash:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.analytics-library:shared:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > androidx.databinding:databinding-compiler-common:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder-test-api:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.utp:android-test-plugin-result-listener-gradle-proto:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:bundletool:1.6.0
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:gradle-api:7.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2 > com.android.tools:common:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2 > com.android.tools.analytics-library:tracker:30.0.2
   Could not find org.jetbrains.kotlin:kotlin-reflect:1.4.32.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-reflect/1.4.32/kotlin-reflect-1.4.32.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2
   Could not find javax.inject:javax.inject:1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/javax/inject/javax.inject/1/javax.inject-1.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:bundletool:1.6.0
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2
   Could not find net.sf.kxml:kxml2:2.3.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.ddms:ddmlib:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.lint:lint-model:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.layoutlib:layoutlib-api:30.0.2
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools.build:builder:7.0.2 > com.android.tools.build:manifest-merger:30.0.2
   Could not find org.jetbrains.intellij.deps:trove4j:1.0.20181211.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/jetbrains/intellij/deps/trove4j/1.0.20181211/trove4j-1.0.20181211.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2
   Could not find xerces:xercesImpl:2.12.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/xerces/xercesImpl/2.12.0/xercesImpl-2.12.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.android.tools.build:gradle:7.0.2 > com.android.tools:sdk-common:30.0.2
   Could not find org.apache.commons:commons-compress:1.20.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/apache/commons/commons-compress/1.20/commons-compress-1.20.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.

ANSWER

Answered 2021-Sep-17 at 11:03

Add mavenCentral() in Build Script

    repositories {
        mavenCentral()
        google()
    }

Source https://stackoverflow.com/questions/69205327

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install javapoet

Download [the latest .jar][dl] or depend via Maven:. Snapshots of the development version are available in [Sonatype’s snapshots repository][snap].

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.