zoukankan      html  css  js  c++  java
  • Android Studio 使用Instagram igjsonparse 类库的配置

    json是现在流行的通用数据格式了,android对它的操作不是很方便,虽然也有gson等lib.instagram新出炉的ig-json-parse自动化操作,自动序列化和反序列化,非常方便。

    就是官方没有使用studio,配置运行费了我一番时间。现在把成功后的配置文件分享下,app目录下的build.gradle(非root目录下的project build文件)要添加如下配置信息:

    apply plugin: 'com.android.application'
    ext {
        generatedSourcesDir = file("gen-src/main/java")
    }
    
    repositories {
        mavenCentral()
    }
    
    
    
    android {
        compileSdkVersion 11
        buildToolsVersion "20.0.0"
    
        defaultConfig {
            applicationId "xxxxxx"
            minSdkVersion 11
            targetSdkVersion 11
        }
    
        sourceSets {
            main {
                java {
                    srcDir generatedSourcesDir
                }
            }
        }
    
        buildTypes {
            release {
                runProguard false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: '*.jar')
        compile 'com.instagram:ig-json-parser-processor:0.0.4+'
    }
    
    tasks.withType(JavaCompile) {
        doFirst {
            // regenerate all files
            if (generatedSourcesDir.exists()) {
                generatedSourcesDir.deleteDir()
            }
            generatedSourcesDir.mkdirs()
        }
        options.compilerArgs += [
                '-processor',
                'com.instagram.common.json.annotation.processor.JsonAnnotationProcessor',
                '-s',
                generatedSourcesDir
        ]
    }

    之后点击如图按钮编译,就会自动生成helper class,进行解析和序列化的工作了。

    具体类库的使用方法,可以参考github官方的说明。

    https://github.com/Instagram/ig-json-parser

  • 相关阅读:
    grunt in webstorm
    10+ Best Responsive HTML5 AngularJS Templates
    响应式布局
    responsive grid
    responsive layout
    js event bubble and capturing
    Understanding Service Types
    To add private variable to this Javascript literal object
    Centering HTML elements larger than their parents
    java5 新特性
  • 原文地址:https://www.cnblogs.com/bluelife/p/4001710.html
Copyright © 2011-2022 走看看